3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Exception { protected $message = 'Unknown exception'; // exception message private $string; // __toString cache protected $code = 0; // user defined exception code protected $file; // source filename of exception protected $line; // source line of exception private $trace; // backtrace private $previous; // previous exception if nested exception public function __construct($message = null, $code = 0, Exception $previous = null); final private function __clone(); // Inhibits cloning of exceptions. final public function getMessage(); // message of exception final public function getCode(); // code of exception final public function getFile(); // source filename final public function getLine(); // source line final public function getTrace(); // an array of the backtrace() final public function getPrevious(); // previous exception final public function getTraceAsString(); // formatted string of trace // Overrideable public function __toString(); // formatted string for display } /** * NewException * Extends the Exception class so that the $message parameter is now mendatory. * */ 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 = self::NONE) { 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 } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.5.40.0100.05317.20
5.5.30.0070.05317.32
5.5.20.0030.06017.19
5.5.10.0000.08717.30
5.5.00.0070.07717.21
5.4.200.0130.07319.12
5.4.190.0030.08319.11
5.4.180.0130.07019.13
5.4.170.0070.07719.08
5.4.160.0130.06319.01
5.4.150.0030.06718.99
5.4.140.0100.06316.43
5.4.130.0100.06716.40
5.4.120.0100.06316.54
5.4.110.0070.05316.35
5.4.100.0100.04316.24
5.4.90.0130.03716.59
5.4.80.0130.04016.41
5.4.70.0100.03316.43
5.4.60.0070.07316.48
5.4.50.0030.08016.39
5.4.40.0100.06716.34
5.4.30.0070.07016.27
5.4.20.0100.06716.45
5.4.10.0030.03716.38
5.4.00.0070.03715.79
5.3.270.0070.06014.65
5.3.260.0100.04314.45
5.3.250.0100.06714.56
5.3.240.0130.06314.67
5.3.230.0070.07014.70
5.3.220.0070.04714.59
5.3.210.0070.08014.61
5.3.200.0030.08014.64
5.3.190.0100.07014.52
5.3.180.0000.06714.63
5.3.170.0000.07314.55
5.3.160.0000.06714.41
5.3.150.0070.07314.55
5.3.140.0130.06714.55
5.3.130.0000.07714.50
5.3.120.0070.05014.59
5.3.110.0100.04314.59
5.3.100.0030.04714.07
5.3.90.0030.05014.08
5.3.80.0070.06714.05
5.3.70.0070.07714.06
5.3.60.0030.04713.89
5.3.50.0070.03713.82
5.3.40.0100.07014.01
5.3.30.0170.06313.95
5.3.20.0130.06713.59
5.3.10.0130.05313.54
5.3.00.0070.07313.85

preferences:
141 ms | 1394 KiB | 7 Q