How to rerurn function values in array ?

[b][embed=425,349]How to rerurn function values in array ?
please help me

<?php class Test { var $arr; var $arr1; function msg($str,$str1) { $msg.=$str.$str1; return $msg; } } $objtest=new Test(); $msgbox[]=$this->msg('pankaj','pankaj'); ?>

[/embed][/b]

  1. $msg.=$str.$str1;
    msg is not set so you can’t append a string to it.

  2. $msgbox[]=$this->msg(‘pankaj’,‘pankaj’);
    $this is used when referencing variables/methods when you are inside an object.

[hr]

[php]class Test
{
private $msg;
private $arr;
private $arr1;

public function __construct()
{
$this->msg = ‘’;
}

function msg($str,$str1)
{
$this->msg .= $str.$str1;
return $this->msg;
}

}
$objtest = new Test();
$msgbox[] = $objtest->msg(‘pankaj’,‘pankaj’);[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service