3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface MyException { } class ImplementingException1 implements MyException { } class ImplementingException2 implements MyException { } function test($var) { if ($var) throw new ImplementingException1; throw new ImplementingException2; } try { test(true); } catch (MyException $e) { get_class($e); }
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Cannot throw objects that do not implement Throwable in /in/maGsp:17 Stack trace: #0 /in/maGsp(23): test(true) #1 {main} thrown in /in/maGsp on line 17
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Fatal error: Exceptions must be valid objects derived from the Exception base class in /in/maGsp on line 17
Process exited with code 255.