3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { function __toString() { return "x"; } } $foo = new foo; var_dump(strpos($foo, "x")); var_dump(strpos("x", $foo)); $array = array("x" => "y"); var_dump($array[$foo]); var_dump($foo[0]);
Output for 7.0.0 - 7.1.0
int(0) Notice: Object of class foo could not be converted to int in /in/C3llB on line 9 bool(false) Warning: Illegal offset type in /in/C3llB on line 11 NULL Fatal error: Uncaught Error: Cannot use object of type foo as array in /in/C3llB:12 Stack trace: #0 {main} thrown in /in/C3llB on line 12
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
int(0) Notice: Object of class foo could not be converted to int in /in/C3llB on line 9 bool(false) Warning: Invalid operand type was used: Invalid type used as key in /in/C3llB on line 11 Notice: Undefined index: x in /in/C3llB on line 11 NULL Fatal error: Object does not implement ArrayAccess in /in/C3llB on line 12
Process exited with code 255.
Output for 5.2.0 - 5.6.28
int(0) Notice: Object of class foo could not be converted to int in /in/C3llB on line 9 bool(false) Warning: Illegal offset type in /in/C3llB on line 11 NULL Fatal error: Cannot use object of type foo as array in /in/C3llB on line 12
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Notice: Object of class foo to string conversion in /in/C3llB on line 8 bool(false) Notice: Object of class foo could not be converted to int in /in/C3llB on line 9 bool(false) Warning: Illegal offset type in /in/C3llB on line 11 NULL Fatal error: Cannot use object of type foo as array in /in/C3llB on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Notice: Object of class foo to string conversion in /in/C3llB on line 8 bool(false) bool(false) Warning: Illegal offset type in /in/C3llB on line 11 NULL Fatal error: Cannot use object of type foo as array in /in/C3llB on line 12
Process exited with code 255.
Output for 4.3.0 - 4.4.9
Notice: Object to string conversion in /in/C3llB on line 8 bool(false) bool(false) Warning: Illegal offset type in /in/C3llB on line 11 NULL NULL