3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL); class RefArray implements ArrayAccess { public $array; public function &offsetGet($key) { return $this->array[$key]; } public function offsetSet($key, $value) { $this->array[$key] = $value; } public function offsetExists($key) { return isset($this->array[$key]); } public function offsetUnset($key) { unset($this->array[$key]); } } $arr = new RefArray; $arr[0] = 'abc'; $arr[1] =& $arr[0];
Output for 5.0.0 - 5.0.4, hhvm-3.12.0, 7.0.0 - 7.1.0
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.5, 5.3.4 - 5.6.28
Fatal error: Cannot assign by reference to overloaded object in /in/k6hMe on line 14
Process exited with code 255.
Output for 5.1.0 - 5.3.3
Fatal error: Declaration of RefArray::offsetGet() must be compatible with that of ArrayAccess::offsetGet() in /in/k6hMe on line 4
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/k6hMe on line 4
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/k6hMe on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/k6hMe on line 4
Process exited with code 255.