3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyException extends Exception { public static function throw($message) { throw new static($message); } } try { $nothing ?? MyException::throw('hooray'); } catch (Exception $e) { echo "Exception caught: $e"; }
based on 3GOtL
Output for 7.0.0 - 7.2.6
Exception caught: MyException: hooray in /in/e49n2:7 Stack trace: #0 /in/e49n2(12): MyException::throw('hooray') #1 {main}
Output for hhvm-3.15.4
Exception caught: exception 'MyException' with message 'hooray' in /in/e49n2:7 Stack trace: #0 /in/e49n2(12): MyException::throw() #1 {main}
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'throw' (T_THROW), expecting identifier (T_STRING) in /in/e49n2 on line 5
Process exited with code 255.