3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function setByLink( Array $tree, &$dst ) { $dst = $tree[0]; $tree[] = 'Hi'; } $tree = new ArrayObject([ new ArrayObject([ 1, 2 ]), 3 ]); setByLink( $tree, $arr ); $arr[] = 'Hello'; var_dump( is_array( $tree ), $tree );
based on d6D7X
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to setByLink() must be of the type array, object given, called in /in/7MOpo on line 16 and defined in /in/7MOpo:3 Stack trace: #0 /in/7MOpo(16): setByLink(Object(ArrayObject), NULL) #1 {main} thrown in /in/7MOpo on line 3
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Catchable fatal error: Argument 1 passed to setByLink() must be of the type array, object given, called in /in/7MOpo on line 16 and defined in /in/7MOpo on line 3
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/7MOpo on line 8
Process exited with code 255.