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', new PreviousException()); } catch (\Exception $e) { var_dump($e); }

preferences:
44.04 ms | 402 KiB | 5 Q