3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class X { function __get($name) { return array('foo' => NULL); } } $x = new X; echo key($x->foo);
Output for 5.0.4 - 5.2.0, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
foo
Output for 5.2.1 - 5.6.28
Notice: Indirect modification of overloaded property X::$foo has no effect in /in/2gPCN on line 8 foo
Output for 5.0.0 - 5.0.3
Fatal error: Cannot access undefined property for object with overloaded property access in /in/2gPCN on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.0, 4.4.2 - 4.4.9
Warning: key(): Passed variable is not an array or object in /in/2gPCN on line 8
Output for 4.4.1
Notice: Undefined property: foo in /in/2gPCN on line 8 Warning: key(): Passed variable is not an array or object in /in/2gPCN on line 8
Output for 4.3.0 - 4.3.1
Warning: key() [http://www.php.net/function.key]: Passed variable is not an array or object in /in/2gPCN on line 8