3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements \ArrayAccess { private $array_access = ['array_access'], $brace_access = ['brace_access']; public function __get ($offset) { return $this->brace_access[$offset]; } public offsetGet ( $offset ) { return $this->array_access[$offset]; } public offsetExists ( $offset ) {} public offsetSet ( $offset , $value ) {} public offsetUnset ( $offset ) {} } $foo = new Foo; echo $foo{0}; echo $foo[0];
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected 'offsetGet' (T_STRING), expecting variable (T_VARIABLE) in /in/W9F2C on line 11
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[' in /in/W9F2C on line 4
Process exited with code 255.

preferences:
184.2 ms | 1394 KiB | 64 Q