<?php
function func(&$arr)
{
$ref = &$arr[0];
echo "in func\n";
// xdebug_debug_zval('arr');
return $arr;
}
func($a);
$b = $a;
$b[0] = '!';
echo "refed by another scope\n";
// xdebug_debug_zval('a');
$b = func($a);
$b[0] = '!';
echo "copy func return refed var\n";
// xdebug_debug_zval('a');
$ref = &$a[0];
$aa = &$a;
$b = $aa;
$b[0] = '!';
echo "refed same scope\n";
// xdebug_debug_zval('a');
PD9waHAKJGEgPSBhcnJheSgxKTsKZnVuY3Rpb24gZnVuYygmJGFycikKewogICRyZWYgPSAmJGFyclswXTsKICBlY2hvICJpbiBmdW5jXG4iOwogIC8vIHhkZWJ1Z19kZWJ1Z196dmFsKCdhcnInKTsKICB2YXJfZHVtcCgkYXJyKTsKICByZXR1cm4gJGFycjsKfQpmdW5jKCRhKTsKJGIgPSAkYTsKJGJbMF0gPSAnISc7CmVjaG8gInJlZmVkIGJ5IGFub3RoZXIgc2NvcGVcbiI7Ci8vIHhkZWJ1Z19kZWJ1Z196dmFsKCdhJyk7CnZhcl9kdW1wKCRhKTsKJGIgPSBmdW5jKCRhKTsKJGJbMF0gPSAnISc7CmVjaG8gImNvcHkgZnVuYyByZXR1cm4gcmVmZWQgdmFyXG4iOwovLyB4ZGVidWdfZGVidWdfenZhbCgnYScpOwp2YXJfZHVtcCgkYSk7CgokYSA9IGFycmF5KDEpOwokcmVmID0gJiRhWzBdOwokYWEgPSAmJGE7CiRiID0gJGFhOwokYlswXSA9ICchJzsKZWNobyAicmVmZWQgc2FtZSBzY29wZVxuIjsKLy8geGRlYnVnX2RlYnVnX3p2YWwoJ2EnKTsKdmFyX2R1bXAoJGEpOwo=