3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php var_dump(1 + 1); // int 2 var_dump('1' + '1'); //int 2 class One { public function __toString() { return '1'; } } var_dump(new One + new One); // Object of class One could not be converted to int int 2 var_dump((string)new One + (string)new One); // int 2 var_dump(2 + 2); // int 4 var_dump('2' + '2'); // int 4 class Two { public function __toString() { return '2'; } } var_dump(new Two + new Two); // Notice: Object of class Two could not be converted to int int 2 var_dump((string)new Two + (string)new Two); // int 4
Output for 5.2.0 - 7.1.0
int(2) int(2) Notice: Object of class One could not be converted to int in /in/BBeQt on line 11 Notice: Object of class One could not be converted to int in /in/BBeQt on line 11 int(2) int(2) int(4) int(4) Notice: Object of class Two could not be converted to int in /in/BBeQt on line 24 Notice: Object of class Two could not be converted to int in /in/BBeQt on line 24 int(2) int(4)
Output for 5.1.1 - 5.1.6
int(2) int(2) Notice: Object of class One could not be converted to int in /in/BBeQt on line 11 Notice: Object of class One could not be converted to int in /in/BBeQt on line 11 int(2) int(0) int(4) int(4) Notice: Object of class Two could not be converted to int in /in/BBeQt on line 24 Notice: Object of class Two could not be converted to int in /in/BBeQt on line 24 int(2) int(0)
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/BBeQt on line 25
Process exited with code 255.
Output for 5.0.0 - 5.0.5
int(2) int(2) Fatal error: Unsupported operand types in /in/BBeQt on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/BBeQt on line 6
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 T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/BBeQt on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/BBeQt on line 6
Process exited with code 255.