3v4l.org

run code in 300+ PHP versions simultaneously
<?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

preferences:
43.27 ms | 402 KiB | 5 Q