3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class SomeArray extends ArrayObject { public function __construct($array) { var_dump('Called: '.__METHOD__); parent::__construct($array); } public function offsetExists($offset) { var_dump('Called: '.__METHOD__); return parent::offsetExists($offset); } public function offsetGet($offset) { var_dump('Called: '.__METHOD__); return parent::offsetGet($offset); } public function offsetSet($offset, $value) { } public function offsetUnset($offset) { } } $array = new ArrayObject(array('foo' => '')); var_dump(isset($array['foo']), empty($array['foo'])); $array = new SomeArray(array('foo' => '')); var_dump(isset($array['foo']), empty($array['foo']));
Output for 5.6.0 - 7.1.0
bool(true) bool(true) string(30) "Called: SomeArray::__construct" string(31) "Called: SomeArray::offsetExists" string(31) "Called: SomeArray::offsetExists" string(28) "Called: SomeArray::offsetGet" bool(true) bool(true)
Output for 5.2.2 - 5.5.38
bool(true) bool(true) string(30) "Called: SomeArray::__construct" string(31) "Called: SomeArray::offsetExists" string(31) "Called: SomeArray::offsetExists" bool(true) bool(false)
Output for 5.2.1
bool(true) bool(true) string(30) "Called: SomeArray::__construct" string(31) "Called: SomeArray::offsetExists" string(31) "Called: SomeArray::offsetExists" bool(false) bool(true)
Output for 5.0.4 - 5.2.0
bool(true) bool(false) string(30) "Called: SomeArray::__construct" string(31) "Called: SomeArray::offsetExists" string(31) "Called: SomeArray::offsetExists" bool(true) bool(false)
Output for 5.0.0 - 5.0.3
bool(true) bool(false) string(30) "Called: SomeArray::__construct" bool(true) bool(false)
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ZPuUS on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ZPuUS on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/ZPuUS on line 5
Process exited with code 255.