3v4l.org

run code in 300+ PHP versions simultaneously
<?php #file: Router/Exception.php namespace Router { interface Exception {} } #file: Router/Exception/NotFound.php namespace Router\Exception { class NotFound extends \NoticeException implements \Router\Exception {} } #file: index.php // now you can catch your exceptions either by the SPL type but also by component try { throw new \Router\Exception\NotFound; } catch (\Router\Exception $e) { var_dump(1, $e); } catch (\NoticeException $e) { var_dump(2, $e); };
Output for 7.0.0 - 7.0.1
Fatal error: No code may exist outside of namespace {} in /in/1jqXY on line 23
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Fatal error: No code may exist outside of namespace {} in /in/1jqXY on line 24
Process exited with code 255.

preferences:
172.34 ms | 1395 KiB | 25 Q