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: var_dump(isset($array['foo'])); //true var_dump(empty($array['foo'])); //false var_dump(isset($array_object['foo'])); //true var_dump(empty($array_object['foo'])); //false echo PHP_EOL; // non-existing key: var_dump(isset($array['bar'])); //false var_dump(empty($array['bar'])); //true var_dump(isset($array_object['bar'])); //true var_dump(empty($array_object['bar'])); //false echo PHP_EOL; // key where value is null: var_dump(isset($array['baz'])); //false var_dump(empty($array['baz'])); //true var_dump(isset($array_object['baz'])); //true var_dump(empty($array_object['baz'])); //false
Output for 5.6.0 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
bool(true) bool(false) bool(true) Called bool(false) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) Called bool(true)
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.5.38
bool(true) bool(false) bool(true) bool(false) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true)
Output for 5.2.1 - 5.3.10, 5.4.0
bool(true) bool(false) bool(true) bool(false) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(true) bool(true)
Output for 5.0.2 - 5.0.5, 5.1.1 - 5.2.0
bool(true) bool(false) bool(true) bool(false) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(true) bool(false)
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/fR47K on line 38
Process exited with code 255.
Output for 5.0.0 - 5.0.1
bool(true) bool(false) bool(true) bool(false) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/fR47K on line 23 PHP_EOLbool(false) bool(true) bool(false) bool(true) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/fR47K on line 31 PHP_EOLbool(false) bool(true) bool(true) bool(false)
Output for 4.3.2 - 4.4.9
Fatal error: Class mystuff: Cannot inherit from undefined class arrayobject in /in/fR47K on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Class mystuff: Cannot inherit from undefined class arrayobject in /in/fR47K on line 3