3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Ints extends ArrayObject { public function offsetGet($index) : int { var_dump('offsetGet'); return parent::offsetGet($index); } } $ints = new Ints([1,2,'foo']); for ($i = 0; $i < 3; $i++) { var_dump($ints[$i]); }
based on RhaUN
Output for 7.3.0alpha1 - 7.3.0rc3
string(9) "offsetGet" int(1) string(9) "offsetGet" int(2) string(9) "offsetGet" Fatal error: Uncaught TypeError: Return value of Ints::offsetGet() must be of the type int, string returned in /in/1njNa:6 Stack trace: #0 /in/1njNa(12): Ints->offsetGet(2) #1 {main} thrown in /in/1njNa on line 6
Process exited with code 255.
Output for 7.0.0 - 7.2.6
string(9) "offsetGet" int(1) string(9) "offsetGet" int(2) string(9) "offsetGet" Fatal error: Uncaught TypeError: Return value of Ints::offsetGet() must be of the type integer, string returned in /in/1njNa:6 Stack trace: #0 /in/1njNa(12): Ints->offsetGet(2) #1 {main} thrown in /in/1njNa on line 6
Process exited with code 255.
Output for hhvm-3.22.0
string(9) "offsetGet" int(1) string(9) "offsetGet" int(2) string(9) "offsetGet" Fatal error: Uncaught TypeError: Value returned from method Ints::offsetGet() must be of type int, string given in /in/1njNa:-1 Stack trace: #0 /in/1njNa(-1): Ints->offsetGet() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
string(9) "offsetGet" int(1) string(9) "offsetGet" int(2) string(9) "offsetGet" Fatal error: Uncaught TypeError: Value returned from method Ints::offsetGet() must be of type int, string given in /in/1njNa:6 Stack trace: #0 /in/1njNa(12): Ints->offsetGet() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/1njNa on line 4
Process exited with code 255.