3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace vendor\package\exception { class Ex1 extends \Exception {} } namespace vendor\package { use vendor\package\exception\Ex1; try { throw new Ex1('Exception 1'); } catch (Ex1 $e) { echo "Catched: ".$e->getMessage()."\n"; }; } namespace vendor\package { use vendor\package\exception as ex; try { throw new ex\Ex1('Exception 2'); } catch (ex\Ex1 $e) { echo "Catched: ".$e->getMessage()."\n"; }; } namespace vendor\package { use vendor\package\exception as ex; try { throw new ex\Ex1('Exception 3'); } catch (\Exception $e) { echo "Catched: ".$e->getMessage()."\n"; }; } namespace vendor\package { use vendor\package\exception as ex; try { throw new ex\Ex1('Exception 4'); } catch (\Throwable $e) { echo "Catched: ".$e->getMessage()."\n"; }; }
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
Catched: Exception 1 Catched: Exception 2 Catched: Exception 3 Catched: Exception 4
Output for 5.6.0 - 5.6.40
Catched: Exception 1 Catched: Exception 2 Catched: Exception 3 Fatal error: Uncaught exception 'vendor\package\exception\Ex1' with message 'Exception 4' in /in/KXISC:38 Stack trace: #0 {main} thrown in /in/KXISC on line 38
Process exited with code 255.

preferences:
107.95 ms | 1996 KiB | 4 Q