奇怪,第一次看到这样子。class test
{
public $test = array();
function test()
{
$this -> test[] = 'ok';
} function _echo()
{
foreach ($this -> test as $val)
echo print_r($val);
}
} $test = new test();
$test -> _echo();
打印出 ok1
{
public $test = array();
function test()
{
$this -> test[] = 'ok';
} function _echo()
{
foreach ($this -> test as $val)
echo print_r($val);
}
} $test = new test();
$test -> _echo();
打印出 ok1
是函数当然会有返回值对于你的应用,应写作
echo print_r($val, 1);
(PHP 4, PHP 5)
print_r -- 打印关于变量的易于理解的信息。
描述
bool print_r ( mixed expression [, bool return] )
---------------------------------------------
既然print_r何必还要echo,如需要也得加上第二个参数echo print_r($var,true);