3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MySampleClass { public function __toString() { return 1; } } try{ $foo = new MySampleClass(); echo " text ".$foo; }catch(Exception $e){ echo "I did not expect anything to go wrong :-)"; }
based on 49JXF
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Method MySampleClass::__toString() must return a string value in /in/geWOZ on line 11
Process exited with code 255.
Output for 5.3.18 - 7.0.20
Catchable fatal error: Method MySampleClass::__toString() must return a string value in /in/geWOZ on line 11
Process exited with code 255.