Esempio n. 1
0
echo "<hr/>\n";
showaRec($a3, 0);
echo "<br/>\n";
// showMat also works for $a3 but it will not always for for nested arrays
showMat($a3);
echo "<hr/>\n";
// modify1 will not actually modify the arrays
modify1($a1);
modify1($a2);
echo "<h3>After modify1 the arrays are:</h3>";
showa($a1);
showa($a2);
// modify2 will modify the parameters within the functions but leave the
// argument arrays unchanged
modify2($a1);
modify2($a2);
echo "<h3>After modify2 the arrays are:</h3>";
showa($a1);
showa($a2);
// modify3 will modify the argument arrays
modify3($a1);
modify3($a2);
echo "<h3>After modify3 the arrays are:</h3>";
showa($a1);
showa($a2);
showaRec($a2, 0);
echo "<hr/>\n";
// Demonstrating local vs. global variables
globloc();
echo "Back in main: <br/>\n";
print_r($a1);
Esempio n. 2
0
    public $hello;
}
//参数不带&,只能改变object的property,没办法改变obj本身
function modify($obj)
{
    $obj->hello = 'world (modified)!';
}
// 只有显示的 对参数 加上&(ampersand),才能改变obj本身
function modify2($obj)
{
    $obj = 32;
}
$obj = new Test();
$obj->hello = 'world';
modify($obj);
modify2($obj);
var_dump($obj->hello);
// outputs "world (modified!)"
// Example one
$arr1 = array(1);
echo "\nbefore:\n";
echo "\$arr1[0] == {$arr1[0]}\n";
$arr2 = $arr1;
$arr2[0]++;
echo "\nafter:\n";
echo "\$arr1[0] == {$arr1[0]}\n";
echo "\$arr2[0] == {$arr2[0]}\n";
// Example two
echo "\nExample2:\n";
$arr3 = array(1);
//xdebug_debug_zval('arr3');