fork(1) download
  1. <?php
  2. $a = array(1);
  3. function func(&$arr)
  4. {
  5. $ref = &$arr[0];
  6. echo "in func\n";
  7. // xdebug_debug_zval('arr');
  8. var_dump($arr);
  9. return $arr;
  10. }
  11. func($a);
  12. $b = $a;
  13. $b[0] = '!';
  14. echo "refed by another scope\n";
  15. // xdebug_debug_zval('a');
  16. $b = func($a);
  17. $b[0] = '!';
  18. echo "copy func return refed var\n";
  19. // xdebug_debug_zval('a');
  20.  
  21. $a = array(1);
  22. $ref = &$a[0];
  23. $aa = &$a;
  24. $b = $aa;
  25. $b[0] = '!';
  26. echo "refed same scope\n";
  27. // xdebug_debug_zval('a');
  28.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
in func
array(1) {
  [0]=>
  &int(1)
}
refed by another scope
array(1) {
  [0]=>
  int(1)
}
in func
array(1) {
  [0]=>
  &int(1)
}
copy func return refed var
array(1) {
  [0]=>
  &string(1) "!"
}
refed same scope
array(1) {
  [0]=>
  &string(1) "!"
}