3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyStuff extends ArrayObject { function offsetGet($offset) { echo "Called", PHP_EOL; return parent::offsetGet($offset); } } $array = array( 'foo' => 42, 'baz' => null, ); $array_object = new MyStuff($array); // existing key, non-null value: assert(isset($array['foo']) === true) ?: echo "isset(existing key, non-null value) failed"; assert(empty($array['foo']) === false); assert(isset($array_object['foo']) === true); assert(empty($array_object['foo']) === false); // non-existing key: assert(isset($array['bar']) === false); assert(empty($array['bar']) === true); assert(isset($array_object['bar']) === false); assert(empty($array_object['bar']) === true); // key where value is null: assert(isset($array['baz']) === false); assert(empty($array['baz']) === true); assert(isset($array_object['baz']) === false); assert(empty($array_object['baz']) === true);
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/fmv44 on line 18
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_ECHO in /in/fmv44 on line 18
Process exited with code 255.