3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NewException extends Exception { //$message is now not optional, just for the extension. public function __construct($message, $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } /** * TestException * Tests and throws Exceptions. */ class TestException { const NONE = 0; const NORMAL = 1; const CUSTOM = 2; public function __construct($type) { switch ($type) { case 1: throw new Exception('Normal Exception'); break; case 2: throw new NewException('Custom Exception'); break; default: return 0; //No exception is thrown. } } } try { $t = new TestException(TestException::CUSTOM); } catch (Exception $e) { print_r($e); //Exception Caught } ?>
Output for git.master, git.master_jit, rfc.property-hooks
NewException Object ( [message:protected] => Custom Exception [string:Exception:private] => [code:protected] => 0 [file:protected] => /in/7MB1t [line:protected] => 24 [trace:Exception:private] => Array ( [0] => Array ( [file] => /in/7MB1t [line] => 33 [function] => __construct [class] => TestException [type] => -> [args] => Array ( [0] => 2 ) ) ) [previous:Exception:private] => )

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:
53.97 ms | 402 KiB | 8 Q