3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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.3.21 - 5.6.16
Fatal error: No code may exist outside of namespace {} in /in/1jqXY on line 24
Process exited with code 255.