3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $foo = new \StdClass; $bar = new \StdClass; $foo->bar = $bar; $bar->foo = $foo; $array = array('foo' => $foo, 'bar' => $bar); $hash = array(); rwalk($array); function rwalk($array) { if (is_array($array)) { foreach ($array as $key => $value) { if (is_object($value)) { $objHash = spl_object_hash($value); $value = (array) $value; } if (is_array($value) && !in_array($objHash, $hash)) { $hash[] = $objHash; //rwalk($value); } else echo "REC"; } } }
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: hash in /in/Xk0kh on line 20 Warning: in_array() expects parameter 2 to be array, null given in /in/Xk0kh on line 20
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: hash in /in/Xk0kh on line 20 Warning: in_array() expects parameter 2 to be an array or collection in /in/Xk0kh on line 20
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 3 Notice: Undefined variable: hash in /in/Xk0kh on line 20 Warning: in_array(): Wrong datatype for second argument in /in/Xk0kh on line 20
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 3 Fatal error: Call to undefined function spl_object_hash() in /in/Xk0kh on line 16
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 3 Fatal error: Call to undefined function: spl_object_hash() in /in/Xk0kh on line 16
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 3 Fatal error: Call to undefined function: spl_object_hash() in /in/Xk0kh on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/Xk0kh on line 3 Fatal error: Call to undefined function: spl_object_hash() in /in/Xk0kh on line 16