3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace HHVM\UserDocumentation\Inconsistencies\Intro\Examples\toStringExc; class A { public function __toString() { throw new \Exception('Not allowed in PHP'); return 'A'; } } $a = new A(); try { echo $a; } catch (\Exception $ex) { echo "Exception will not be thrown to here in PHP"; }
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Exception will not be thrown to here in PHP
Output for 7.0.1 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Fatal error: Method HHVM\UserDocumentation\Inconsistencies\Intro\Examples\toStringExc\A::__toString() must not throw an exception, caught Exception: Not allowed in PHP in /in/XHDP8 on line 0
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0
Fatal error: Method HHVM\UserDocumentation\Inconsistencies\Intro\Examples\toStringExc\A::__toString() must not throw an exception in /in/XHDP8 on line 0
Process exited with code 255.

preferences:
245.94 ms | 402 KiB | 330 Q