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 One()); } catch (\Exception $e) { var_dump($e); }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Two::__construct(): Argument #2 ($e) must be of type PreviousException, One given, called in /in/a3ErJ on line 19 and defined in /in/a3ErJ:13 Stack trace: #0 /in/a3ErJ(19): Two->__construct('Throwing two, b...', Object(One)) #1 {main} thrown in /in/a3ErJ on line 13
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.39 ms | 401 KiB | 8 Q