3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A implements ArrayAccess { public function offsetGet($offset) { echo "get: "; var_dump($offset); return "value"; } public function offsetSet($offset, $value) { echo "set: = $value: "; var_dump($offset); } public function offsetExists($offset) { echo "isset: "; var_dump($offset); return false; } public function offsetUnset($offset) { echo "unset: "; var_dump($offset); } } $a = new A(); var_dump($a[42]); $a[37] = 19; var_dump(isset($a[23])); unset($a[41]);
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
get: int(42) string(5) "value" set: = 19: int(37) isset: int(23) bool(false) unset: int(41)
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/VM5NO on line 2
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 '{' in /in/VM5NO on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/VM5NO on line 2
Process exited with code 255.