3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PreviousException extends \Exception {} class One extends \RuntimeException { // Just a standard exception } class Two extends \RuntimeException{ // An exception with custom constructor parameters public function __construct($customMessage, PreviousException $e) { parent::__construct($customMessage . "LOL", $e->getCode(), $e); } } try { throw new Two('Throwing "Two", but catch will receive a different class type if I specify just "\Exception" in the catch statement not "Two"', new PreviousException()); } catch (\Exception $e) { var_dump($e); }

preferences:
36.11 ms | 402 KiB | 5 Q