3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyException extends Exception {} class My2Exception extends Exception {} function consume(MyException $e) { var_dump(get_class($e)); } consume(new MyException); consume(new My2Exception);
based on civoL
Output for 7.0.0 - 7.2.0
string(11) "MyException" Fatal error: Uncaught TypeError: Argument 1 passed to consume() must be an instance of MyException, instance of My2Exception given, called in /in/Hlh9i on line 11 and defined in /in/Hlh9i:6 Stack trace: #0 /in/Hlh9i(11): consume(Object(My2Exception)) #1 {main} thrown in /in/Hlh9i on line 6
Process exited with code 255.
Output for 5.3.21 - 5.6.28
string(11) "MyException" Catchable fatal error: Argument 1 passed to consume() must be an instance of MyException, instance of My2Exception given, called in /in/Hlh9i on line 11 and defined in /in/Hlh9i on line 6
Process exited with code 255.