3v4l.org

run code in 300+ PHP versions simultaneously
<?php //use ErrorException; //use InvalidArgumentException; /** * HTTP Status values have a code (int) and reason (string). * * @internal Implemented similar to a type-safe enum. * * @property-read int $code the status code * @property-read string $reason the status description */ final class Status { /** @var array (int) code => (string) reason */ private static $codeReasons = [ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 511 => 'Network Authentication Required', ]; /** @var self[] */ private static $instances = []; /** @var int */ private $code; /** @var string */ private $reason; /** * Singleton constructor * * @param int $aCode an http status code * @throws InvalidArgumentException on invalid code */ private function __construct($aCode) { if (!static::validate($aCode)) { throw new InvalidArgumentExeption("Invalid status code: [$aCode]"); } $this->code = (int) $aCode; $this->reason = static::$codeReasons[$this->code]; } /** * Factory constructor * * Methods must not start with a number, so an underscore prefix is necessary. * * @example $status = Status::_404(); * * @param string $aMethod a status code prefixed with an underscore * @param array $arguments unused arguments passed to the magic method * @return self */ public static function __callStatic($aMethod, array $arguments = []) { $aMethod = trim($aMethod, '_'); if (!isset(static::$instances[$aMethod])) { static::$instances[$aMethod] = new static($aMethod); } return static::$instances[$aMethod]; } /** * List all HTTP statuses * * @yield self */ public static function listAll() { foreach (static::$codeReasons as $code => $reason) { yield $code => $reason; } } /** * Verify that a code is valid * * @param int $aCode the status code to verify * @return bool */ public static function validate($aCode) { return ($aCode instanceof self) || isset(static::$codeReasons[(int) $aCode]); } /** * Allow public property access * * @param string $aProperty * @return mixed * @throws ErrorException on invalid property */ public function __get($aProperty) { if (property_exists($this, $aProperty)) { return $this->{$aProperty}; } $debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $error = sprintf('Undefined property %s::$%s', __CLASS__, $aProperty); throw new ErrorException($error, 0, E_USER_NOTICE, $debug[1]['file'], $debug[1]['line']); } /** @return string */ public function __toString() { return $this->code . ' ' . $this->reason; } } var_dump(iterator_to_array(Status::listAll()));

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)
8.3.60.0140.00416.75
8.3.50.0120.00317.79
8.3.40.0100.00618.79
8.3.30.0070.01119.04
8.3.20.0000.00820.34
8.3.10.0080.00021.77
8.3.00.0040.00419.25
8.2.180.0100.00718.41
8.2.170.0110.00722.96
8.2.160.0150.00420.52
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.01219.36
8.2.110.0040.00422.31
8.2.100.0080.00817.91
8.2.90.0000.00818.03
8.2.80.0000.00818.61
8.2.70.0040.00617.38
8.2.60.0050.00317.93
8.2.50.0030.00518.07
8.2.40.0030.00620.10
8.2.30.0050.00318.02
8.2.20.0040.00417.64
8.2.10.0000.00817.98
8.2.00.0000.00817.61
8.1.280.0090.00625.92
8.1.270.0060.00318.91
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0090.00020.27
8.1.230.0000.01217.70
8.1.220.0080.00017.78
8.1.210.0030.00618.77
8.1.200.0060.00317.23
8.1.190.0040.00417.36
8.1.180.0030.00518.10
8.1.170.0040.00418.59
8.1.160.0000.00818.98
8.1.150.0000.00818.98
8.1.140.0040.00417.51
8.1.130.0000.00717.86
8.1.120.0000.00817.55
8.1.110.0060.00317.41
8.1.100.0030.00517.49
8.1.90.0040.00417.51
8.1.80.0040.00417.39
8.1.70.0040.00417.54
8.1.60.0060.00317.51
8.1.50.0060.00317.51
8.1.40.0030.00517.47
8.1.30.0080.00017.69
8.1.20.0040.00417.76
8.1.10.0050.00317.59
8.1.00.0080.00017.44
8.0.300.0060.00318.77
8.0.290.0080.00016.75
8.0.280.0000.00718.42
8.0.270.0000.00716.74
8.0.260.0000.00717.22
8.0.250.0040.00316.96
8.0.240.0030.00616.99
8.0.230.0030.00317.02
8.0.220.0050.00316.85
8.0.210.0040.00416.81
8.0.200.0050.00317.00
8.0.190.0000.00716.91
8.0.180.0040.00416.98
8.0.170.0040.00417.04
8.0.160.0080.00016.94
8.0.150.0040.00416.91
8.0.140.0040.00416.82
8.0.130.0020.00513.33
8.0.120.0090.00016.87
8.0.110.0000.00816.78
8.0.100.0070.00016.90
8.0.90.0000.00716.91
8.0.80.0120.00417.00
8.0.70.0040.00417.06
8.0.60.0060.00316.94
8.0.50.0040.00417.05
8.0.30.0070.01617.19
8.0.20.0120.00817.40
8.0.10.0040.00417.04
8.0.00.0170.00716.72
7.4.330.0060.00015.03
7.4.320.0030.00316.70
7.4.300.0000.00716.66
7.4.290.0070.00016.48
7.4.280.0040.00416.66
7.4.270.0050.00316.51
7.4.260.0040.00416.55
7.4.250.0000.00816.61
7.4.240.0000.00716.66
7.4.230.0000.00716.48
7.4.220.0060.02216.62
7.4.210.0020.01716.68
7.4.200.0030.00416.36
7.4.160.0090.00916.72
7.4.150.0160.00317.40
7.4.140.0130.00817.86
7.4.130.0120.00716.65
7.4.120.0140.00916.48
7.4.110.0100.01016.47
7.4.100.0140.00716.46
7.4.90.0110.00916.79
7.4.80.0150.00319.39
7.4.70.0100.01016.57
7.4.60.0110.00716.60
7.4.50.0030.00616.63
7.4.40.0030.01416.70
7.4.30.0170.00916.66
7.4.00.0070.01114.95
7.3.330.0000.00613.48
7.3.320.0150.00313.44
7.3.310.0030.00516.51
7.3.300.0040.00416.42
7.3.290.0070.00016.43
7.3.280.0060.01116.39
7.3.270.0090.01117.40
7.3.260.0160.01016.42
7.3.250.0140.00916.44
7.3.240.0120.00616.36
7.3.230.0120.00916.60
7.3.210.0120.01216.60
7.3.200.0100.00619.39
7.3.190.0110.00716.41
7.3.180.0060.01216.52
7.3.170.0110.00816.63
7.3.160.0130.00916.35
7.2.330.0110.00716.71
7.2.320.0190.00316.53
7.2.310.0160.00716.58
7.2.300.0110.01616.68
7.2.290.0090.00916.88
7.2.60.0100.00016.87
7.2.00.0060.00619.17
7.1.200.0060.01015.56
7.1.100.0030.01017.99
7.1.70.0030.00717.09
7.1.60.0110.00619.50
7.1.50.0100.01416.63
7.1.00.0030.07722.42
7.0.200.0150.00414.84
7.0.140.0100.06022.02
7.0.60.0200.05020.00
7.0.50.0130.07717.93
7.0.40.0100.07320.18
7.0.30.0230.05320.12
7.0.20.0100.04720.09
7.0.10.0070.08320.15
7.0.00.0070.06020.09
5.6.280.0070.07021.08
5.6.210.0130.08020.51
5.6.200.0030.08018.18
5.6.190.0100.04720.45
5.6.180.3670.04720.61
5.6.170.0300.07320.54
5.6.160.0100.05320.48
5.6.150.0130.03718.25
5.6.140.0030.08318.14
5.6.130.0030.09018.20
5.6.120.0130.07721.13
5.6.110.0100.08020.99
5.6.100.0030.04721.04
5.6.90.0070.05021.01
5.6.80.0130.06720.41
5.6.70.4070.03320.46
5.5.350.0000.09020.55
5.5.340.0030.04017.97
5.5.330.0130.06720.31
5.5.320.0300.07320.31
5.5.310.0370.06720.35
5.5.300.0170.05717.97
5.5.290.0100.04318.08
5.5.280.0070.05320.80
5.5.270.0000.09720.79
5.5.260.0130.08320.98
5.5.250.0070.08720.82
5.5.240.0070.07320.21
5.4.450.0530.05319.20
5.4.440.1270.06719.57
5.4.430.0800.06019.33
5.4.420.0870.05319.55
5.4.410.0130.07319.08
5.4.400.1330.08318.59
5.4.390.1430.07018.54
5.4.380.1600.05718.66
5.4.370.1500.06318.57
5.4.360.1170.05318.65
5.4.350.1270.05718.57
5.4.340.1100.05318.47
5.4.320.1030.07018.57
5.4.310.1370.05318.61
5.4.300.1200.06718.68
5.4.290.1100.06318.69
5.4.280.1100.05718.70
5.4.270.1330.06318.60
5.4.260.1370.06018.75
5.4.250.1330.06318.73
5.4.240.1530.06318.57
5.4.230.1070.05018.52
5.4.220.1170.06718.74
5.4.210.1470.07018.56
5.4.200.1200.04316.55
5.4.190.1030.07018.73
5.4.180.1500.06018.74
5.4.170.1070.06318.55
5.4.160.1100.06018.56
5.4.150.1230.04718.73
5.4.140.1130.04716.36
5.4.130.1530.05316.45
5.4.120.1200.05316.31
5.4.110.1330.04016.46
5.4.100.1330.07316.36
5.4.90.1270.07016.44
5.4.80.1270.04316.18
5.4.70.1070.05316.33
5.4.60.1070.04316.21
5.4.50.1000.05316.20
5.4.40.1300.05716.29
5.4.30.1230.05716.40
5.4.20.1270.05316.18
5.4.10.1330.04316.28
5.4.00.1300.04715.66
5.3.290.1170.07014.80
5.3.280.1030.06314.75
5.3.270.1330.07014.60
5.3.260.1170.05714.66
5.3.250.1200.05014.63
5.3.240.1100.07314.63
5.3.230.1070.05714.69
5.3.220.1230.04314.59
5.3.210.1470.04714.58
5.3.200.1330.06314.77
5.3.190.1230.06314.55
5.3.180.1100.06314.66
5.3.170.1070.06014.78
5.3.160.1570.07014.66
5.3.150.1300.07014.72
5.3.140.1300.06714.57
5.3.130.1270.06314.65
5.3.120.1400.04714.70
5.3.110.1370.04014.71
5.3.100.1200.06014.14
5.3.90.1200.05314.02
5.3.80.1230.05714.01
5.3.70.1200.06714.14
5.3.60.1400.06314.03
5.3.50.1570.04713.99
5.3.40.1270.06713.96
5.3.30.1030.06014.13
5.3.20.1330.07313.80
5.3.10.1130.07713.75
5.3.00.1400.06313.66
5.2.170.1130.03711.16
5.2.160.0970.04311.18
5.2.150.0900.03711.14
5.2.140.0800.04711.36
5.2.130.0900.03711.30
5.2.120.0870.04011.20
5.2.110.0870.04011.15
5.2.100.0900.04011.09
5.2.90.1300.05011.31
5.2.80.0870.04311.20
5.2.70.0970.05011.13
5.2.60.0970.04710.99
5.2.50.0930.04711.05
5.2.40.0770.05310.99
5.2.30.0900.04711.08
5.2.20.0800.04711.16
5.2.10.0830.03310.84
5.2.00.0830.03710.71
5.1.60.0870.03310.02
5.1.50.0870.03310.20
5.1.40.0670.03710.11
5.1.30.0630.04710.33
5.1.20.0830.04710.55
5.1.10.0800.03010.05
5.1.00.0700.03310.27
5.0.50.0430.0238.69
5.0.40.0330.0308.54
5.0.30.0370.0438.24
5.0.20.0370.0338.22
5.0.10.0500.0338.15
5.0.00.0400.0438.20
4.4.90.0400.0275.92
4.4.80.0400.0235.89
4.4.70.0370.0305.94
4.4.60.0330.0235.91
4.4.50.0370.0205.90
4.4.40.0400.0335.82
4.4.30.0370.0275.89
4.4.20.0370.0235.97
4.4.10.0530.0235.97
4.4.00.0430.0305.98
4.3.110.0330.0235.80
4.3.100.0470.0205.82
4.3.90.0400.0205.78
4.3.80.0300.0375.78
4.3.70.0430.0205.86
4.3.60.0430.0175.82
4.3.50.0430.0235.81
4.3.40.0400.0405.80
4.3.30.0170.0274.66
4.3.20.0170.0274.54
4.3.10.0230.0234.50
4.3.00.0000.0277.04

preferences:
45.49 ms | 400 KiB | 5 Q