3v4l.org

run code in 300+ PHP versions simultaneously
<?php function accept_int(int $value) { return $value; } function accept_float(float $value) { return $value; } function accept_string(string $value) { return $value; } function accept_bool(bool $value) { return $value; } $scalarTypes = ['int', 'float', 'string', 'bool']; $data = [ 'int' => 1, 'int-negative' => -1, 'int-zero' => 0, 'float' => 1.2, 'float-negative' => -1.2, 'float-int' => 1.0, 'float-zero' => 0.0, 'string' => 'abc', 'string-empty' => '', 'string-space' => ' ', 'string-int' => '1', 'string-int-negative' => '-1', 'string-int-zero' => '0', 'string-int-spacepad' => ' 1', 'string-int-start' => '1abc', 'string-int-start-spacepad' => ' 1abc', 'string-float' => '1.2', 'string-float-negative' => '-1.2', 'string-float-int' => '1.0', 'string-float-zero' => '0.0', 'string-float-spacepad' => ' 1.2', 'string-float-spacepad-negative' => ' -1.2', 'string-float-start' => '1.2abc', 'string-float-start-negative' => '-1.2abc', 'string-float-start-spacepad' => ' 1.2abc', 'string-float-start-spacepad-negative' => ' -1.2abc', 'bool-true' => true, 'bool-false' => false, ]; function printValue($value) { if (is_string($value)) { return "\"$value\""; } if (is_bool($value)) { return $value ? 'true' : 'false'; } if (is_float($value)) { return number_format($value, 1); } return $value; } $resultsTable = []; foreach ($scalarTypes as $type) { foreach ($data as $key => $value) { $lineKey = $key . ': ' . printValue($value); $acceptFunction = "accept_$type"; try { $deprecatedFlag = false; $noticeFlag = false; set_error_handler(function (int $errno, string $errstr) use (&$deprecatedFlag, &$noticeFlag) { if ($errno === E_NOTICE) { $noticeFlag = true; } else { $deprecatedFlag = true; } echo $errstr . "\n"; }, E_DEPRECATED | E_NOTICE); $result = $acceptFunction($value); set_error_handler(null); if ($result === $value) { $op = 'ok'; } else { $op = 'coerced to ' . printValue($result); if ($deprecatedFlag) { $op .= ' (D)'; } if ($noticeFlag) { $op .= ' (N)'; } } } catch (Throwable $e) { $op = 'error'; } if (!isset($resultsTable[$lineKey])) { $resultsTable[$lineKey] = []; } $resultsTable[$lineKey][$type] = "$op"; } } echo "\n\nResults table:\n\n"; echo ' | ' . str_pad('data type: data', 50, ' ', STR_PAD_LEFT) . ' | '; foreach ($scalarTypes as $type) { echo str_pad($type, 20) . ' | '; } echo "\n"; echo ' | ' . str_pad('', 50, '-') . ' | '; foreach ($scalarTypes as $type) { echo str_pad('', 20, '-') . ' | '; } echo "\n"; foreach ($resultsTable as $key => $results) { echo ' | ' . str_pad($key, 50, ' ', STR_PAD_LEFT) . ' | '; foreach ($results as $type => $result) { echo str_pad($result, 20) . ' | '; } echo "\n"; }

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.4.120.0120.01122.51
8.4.110.0130.00822.52
8.4.100.0150.00618.17
8.4.90.0040.00820.73
8.4.80.0110.00318.12
8.4.70.0110.01218.16
8.4.60.0140.00720.55
8.4.50.0120.00917.81
8.4.40.0170.00717.84
8.4.30.0080.00619.05
8.4.20.0060.00319.79
8.4.10.0060.00319.54
8.3.250.0130.00718.95
8.3.240.0100.01017.48
8.3.230.0150.00616.73
8.3.220.0060.00219.01
8.3.210.0100.01016.91
8.3.200.0070.00217.09
8.3.190.0130.01017.45
8.3.180.0080.00316.71
8.3.170.0120.00920.65
8.3.160.0110.00717.07
8.3.150.0070.01417.18
8.3.140.0060.00317.39
8.3.130.0060.00318.41
8.3.120.0130.00318.65
8.3.110.0080.00016.92
8.3.100.0040.00420.76
8.3.90.0050.00316.72
8.3.80.0360.01430.84
8.3.70.0420.00330.84
8.3.60.0370.00830.84
8.3.50.0200.01130.84
8.3.40.0380.00730.84
8.3.30.0350.00530.84
8.3.20.0240.00830.84
8.3.10.0240.00630.84
8.3.00.0290.00330.84
8.2.290.0120.00720.50
8.2.280.0070.00419.01
8.2.270.0080.00017.51
8.2.260.0070.01118.77
8.2.250.0080.00017.04
8.2.240.0050.00319.04
8.2.230.0060.00320.94
8.2.220.0100.00024.06
8.2.210.0080.00026.77
8.2.200.0280.00630.84
8.2.190.0250.00630.84
8.2.180.0220.00830.84
8.2.170.0300.00630.84
8.2.160.0300.00730.84
8.2.150.0290.00530.84
8.2.140.0150.00530.84
8.2.130.0280.00430.84
8.2.120.0310.01030.84
8.2.110.0320.00930.84
8.2.100.0350.00530.84
8.2.90.0290.01030.84
8.2.80.0280.00930.84
8.2.70.0310.00930.84
8.2.60.0320.00930.84
8.2.50.0350.00830.84
8.2.40.0280.01230.84
8.2.30.0330.00230.84
8.2.20.0390.00230.84
8.2.10.0360.00930.84
8.2.00.0350.01030.84
8.1.330.0100.00923.94
8.1.320.0130.00718.04
8.1.310.0030.01717.09
8.1.300.0090.00918.09
8.1.290.0230.00830.84
8.1.280.0280.00730.84
8.1.270.0290.00330.84
8.1.260.0370.00530.84
8.1.250.0320.01030.84
8.1.240.0270.00530.84
8.1.230.0260.01130.84
8.1.220.0260.01530.84
8.1.210.0440.00430.84
8.1.200.0330.01330.84
8.1.190.0320.01130.84
8.1.180.0300.00930.84
8.1.170.0270.01230.84
8.1.160.0270.01230.84
8.1.150.0310.01030.84
8.1.140.0300.01130.84
8.1.130.0340.00730.84
8.1.120.0460.00530.84
8.1.110.0410.00530.84
8.1.100.0220.00630.84
8.1.90.0230.00230.84
8.1.80.0250.00130.84
8.1.70.0330.00530.84
8.1.60.0320.00730.84
8.1.50.0380.00230.84
8.1.40.0290.00930.84
8.1.30.0260.00830.84
8.1.20.0220.01130.84
8.1.10.0320.00530.84
8.1.00.0280.00930.84
8.0.300.0340.00830.84
8.0.290.0190.00630.84
8.0.280.0240.00430.84
8.0.270.0160.00730.84
8.0.260.0150.00430.84
8.0.250.0210.00030.84
8.0.240.0190.00030.84
8.0.230.0180.00030.84
8.0.220.0160.00330.84
8.0.210.0190.00030.84
8.0.200.0190.00030.84
8.0.190.0140.00730.84
8.0.180.0210.00030.84
8.0.170.0130.00630.84
8.0.160.0110.01130.84
8.0.150.0180.00430.84
8.0.140.0150.00730.84
8.0.130.0170.00330.84
8.0.120.0160.00230.84
8.0.110.0210.00030.84
8.0.100.0230.00330.84
8.0.90.0100.01030.84
8.0.80.0170.00330.84
8.0.70.0160.00330.84
8.0.60.0120.01230.84
8.0.50.0120.00630.84
8.0.30.0200.00030.84
8.0.20.0170.00330.84
8.0.10.0110.00730.84
8.0.00.0060.00630.84
7.4.330.0160.00530.84
7.4.320.0120.00630.84
7.4.300.0140.01130.84
7.4.290.0160.01630.84
7.4.280.0150.01130.84
7.4.270.0140.00430.84
7.4.260.0250.00030.84
7.4.250.0190.00030.84
7.4.240.0180.00630.84
7.4.230.0230.01130.84
7.4.220.0180.00730.84
7.4.210.0150.00430.84
7.4.200.0230.00030.84
7.4.190.0200.00730.84
7.4.180.0190.01130.84
7.4.160.0340.01330.84
7.4.150.0310.01030.84
7.4.140.0210.00630.84
7.4.130.0100.00730.84
7.4.120.0160.00030.84
7.4.110.0160.01230.84
7.4.100.0170.00330.84
7.4.90.0150.01030.84
7.4.80.0110.00830.84
7.4.70.0200.00030.84
7.4.60.0150.00330.84
7.4.50.0200.00830.84
7.4.40.0250.00030.84
7.4.30.0200.00030.84
7.4.20.0230.01230.84
7.4.10.0210.00030.84
7.4.00.0280.00630.84
7.3.330.0140.00830.84
7.3.320.0140.00330.84
7.3.310.0160.00030.84
7.3.300.0100.00630.84
7.3.290.0130.00230.84
7.3.280.0160.01330.84
7.3.270.0310.00330.84
7.3.260.0150.00830.84
7.3.250.0230.00030.84
7.3.240.0140.00230.84
7.3.230.0100.00530.84
7.3.220.0300.00330.84
7.3.210.0250.00830.84
7.3.200.0260.00330.84
7.3.190.0280.01630.84
7.3.180.0320.00530.84
7.3.170.0270.00930.84
7.3.160.0290.00630.84
7.3.150.0260.01030.84
7.3.140.0310.00430.84
7.3.130.0250.01230.84
7.3.120.0250.01230.84
7.3.110.0320.00430.84
7.3.100.0280.00630.84
7.3.90.0320.00430.84
7.3.80.0240.01030.84
7.3.70.0280.00930.84
7.3.60.0420.00030.84
7.3.50.0240.00030.84
7.3.40.0290.00030.84
7.3.30.0190.00830.84
7.3.20.0200.00730.84
7.3.10.0300.00530.84
7.3.00.0280.00930.84
7.2.340.0320.00430.84
7.2.330.0330.00430.84
7.2.320.0360.00330.84
7.2.310.0190.01530.84
7.2.300.0180.00730.84
7.2.290.0320.00430.84
7.2.280.0280.00430.84
7.2.270.0290.00930.84
7.2.260.0290.00730.84
7.2.250.0280.01230.84
7.2.240.0210.01430.84
7.2.230.0370.00430.84
7.2.220.0270.00930.84
7.2.210.0280.00830.84
7.2.200.0220.01330.84
7.2.190.0320.00330.84
7.2.180.0260.00930.84
7.2.170.0260.01230.84
7.2.160.0260.01030.84
7.2.150.0270.00830.84
7.2.140.0100.01530.84
7.2.130.0190.01530.84
7.2.120.0380.01030.84
7.2.110.0300.00930.84
7.2.100.0170.01730.84
7.2.90.0200.01530.84
7.2.80.0200.01230.84
7.2.70.0120.00630.84
7.2.60.0130.00430.84
7.2.50.0120.00830.84
7.2.40.0140.00530.84
7.2.30.0110.00730.84
7.2.20.0140.00630.84
7.2.10.0180.00030.84
7.2.00.0160.00430.84
7.1.330.0100.00530.84
7.1.320.0120.00330.84
7.1.310.0150.00430.84
7.1.300.0190.00030.84
7.1.290.0130.00330.84
7.1.280.0130.00530.84
7.1.270.0150.00030.84
7.1.260.0180.00030.84
7.1.250.0080.00830.84
7.1.240.0180.00030.84
7.1.230.0160.00430.84
7.1.220.0190.00030.84
7.1.210.0120.00630.84
7.1.200.0100.00730.84
7.1.190.0160.00030.84
7.1.180.0160.00530.84
7.1.170.0070.01030.84
7.1.160.0190.00030.84
7.1.150.0130.00230.84
7.1.140.0160.00030.84
7.1.130.0120.00430.84
7.1.120.0160.00030.84
7.1.110.0140.00230.84
7.1.100.0200.00030.84
7.1.90.0140.00330.84
7.1.80.0140.00230.84
7.1.70.0180.00030.84
7.1.60.0160.00330.84
7.1.50.0150.00630.84
7.1.40.0140.00330.84
7.1.30.0160.00330.84
7.1.20.0120.00630.84
7.1.10.0060.01230.84
7.1.00.0130.00330.84
7.0.330.0120.00330.84
7.0.320.0140.00430.84
7.0.310.0140.00330.84
7.0.300.0110.00530.84
7.0.290.0110.00530.84
7.0.280.0150.00030.84
7.0.270.0130.00330.84
7.0.260.0120.00630.84
7.0.250.0120.00530.84
7.0.240.0200.00030.84
7.0.230.0110.00730.84
7.0.220.0150.00430.84
7.0.210.0130.00330.84
7.0.200.0120.00630.84
7.0.190.0140.00330.84
7.0.180.0170.00030.84
7.0.170.0180.00030.84
7.0.160.0110.00430.84
7.0.150.0090.00930.84
7.0.140.0100.00530.84
7.0.130.0130.00330.84
7.0.120.0150.00030.84
7.0.110.0110.00430.84
7.0.100.0110.00330.84
7.0.90.0130.00330.84
7.0.80.0110.00430.84
7.0.70.0090.00530.84
7.0.60.0100.00530.84
7.0.50.0140.00030.84
7.0.40.0090.00530.84
7.0.30.0130.00030.84
7.0.20.0110.00330.84
7.0.10.0110.00330.84
7.0.00.0090.00430.84
5.6.400.0180.00430.84
5.6.390.0230.00730.84
5.6.380.0180.01330.84
5.6.370.0250.00830.84
5.6.360.0180.00630.84
5.6.350.0280.01130.84
5.6.340.0220.00930.84
5.6.330.0190.00630.84
5.6.320.0070.00730.84
5.6.310.0130.00030.84
5.6.300.0130.00030.84
5.6.290.0140.00030.84
5.6.280.0070.00730.84
5.6.270.0080.00830.84
5.6.260.0140.00030.84
5.6.250.0100.00330.84
5.6.240.0150.00030.84
5.6.230.0160.00030.84
5.6.220.0080.00830.84
5.6.210.0080.00830.84
5.6.200.0120.00230.84
5.6.190.0100.00530.84
5.6.180.0100.00530.84
5.6.170.0150.00030.84
5.6.160.0190.00030.84
5.6.150.0150.00330.84
5.6.140.0070.00730.84
5.6.130.0220.00030.84
5.6.120.0240.00330.84
5.6.110.0070.00730.84
5.6.100.0160.00330.84
5.6.90.0150.00030.84
5.6.80.0110.00830.84
5.6.70.0210.00430.84
5.6.60.0130.00330.84
5.6.50.0100.00830.84
5.6.40.0160.00030.84
5.6.30.0120.00330.84
5.6.20.0100.00730.84
5.6.10.0110.00430.84
5.6.00.0110.00430.84
5.5.380.0170.00030.84
5.5.370.0140.00430.84
5.5.360.0150.00430.84
5.5.350.0100.00530.84
5.5.340.0170.00030.84
5.5.330.0070.00730.84
5.5.320.0140.00330.84
5.5.310.0150.00030.84
5.5.300.0150.00030.84
5.5.290.0080.00830.84
5.5.280.0040.01130.84
5.5.270.0090.00630.84
5.5.260.0160.00030.84
5.5.250.0120.00430.84
5.5.240.0120.00430.84
5.5.230.0130.00330.84
5.5.220.0120.00330.84
5.5.210.0120.00430.84
5.5.200.0100.00530.84
5.5.190.0150.00030.84
5.5.180.0150.00030.84
5.5.170.0080.00630.84
5.5.160.0120.00330.84
5.5.150.0140.00530.84
5.5.140.0140.00330.84
5.5.130.0180.00330.84
5.5.120.0080.00830.84
5.5.110.0090.00630.84
5.5.100.0110.00430.84
5.5.90.0090.00530.84
5.5.80.0130.00230.84
5.5.70.0120.00230.84
5.5.60.0120.00330.84
5.5.50.0140.00030.84
5.5.40.0060.00930.84
5.5.30.0110.00330.84
5.5.20.0140.00030.84
5.5.10.0150.00030.84
5.5.00.0140.00030.84
5.4.450.0060.00630.84
5.4.440.0070.00430.84
5.4.430.0100.00630.84
5.4.420.0100.00330.84
5.4.410.0070.00530.84
5.4.400.0060.00630.84
5.4.390.0090.00330.84
5.4.380.0050.00530.84
5.4.370.0050.00730.84
5.4.360.0110.00030.84
5.4.350.0060.00630.84
5.4.340.0120.00030.84
5.4.330.0120.00030.84
5.4.320.0080.00430.84
5.4.310.0120.00030.84
5.4.300.0090.00230.84
5.4.290.0100.00330.84
5.4.280.0110.00030.84
5.4.270.0090.00330.84
5.4.260.0100.00030.84
5.4.250.0120.00030.84
5.4.240.0050.00530.84
5.4.230.0110.00030.84
5.4.220.0110.00330.84
5.4.210.0100.00330.84
5.4.200.0090.00430.84
5.4.190.0100.00330.84
5.4.180.0100.00330.84
5.4.170.0090.00530.84
5.4.160.0110.00030.84
5.4.150.0100.00030.84
5.4.140.0070.00330.84
5.4.130.0080.00230.84
5.4.120.0100.00030.84
5.4.110.0070.00530.84
5.4.100.0120.00030.84
5.4.90.0100.00030.84
5.4.80.0100.00030.84
5.4.70.0100.00030.84
5.4.60.0050.00530.84
5.4.50.0080.00330.84
5.4.40.0030.00730.84
5.4.30.0030.00830.84
5.4.20.0070.00730.84
5.4.10.0100.00030.84
5.4.00.0050.00530.84
5.3.290.0100.00030.84
5.3.280.0130.00030.84
5.3.270.0070.00730.84
5.3.260.0110.00430.84
5.3.250.0140.00430.84
5.3.240.0110.00030.84
5.3.230.0120.00030.84
5.3.220.0060.00630.84
5.3.210.0080.00330.84
5.3.200.0100.00030.84
5.3.190.0080.00330.84
5.3.180.0100.00030.84
5.3.170.0070.00330.84
5.3.160.0100.00030.84
5.3.150.0050.00530.84
5.3.140.0100.00030.84
5.3.130.0180.00030.84
5.3.120.0130.00630.84
5.3.110.0130.01330.84
5.3.100.0110.01430.84
5.3.90.0190.00630.84
5.3.80.0110.01130.84
5.3.70.0140.00730.84
5.3.60.0230.00030.84
5.3.50.0160.00430.84
5.3.40.0160.00030.84
5.3.30.0150.00030.84
5.3.20.0100.00030.84
5.3.10.0000.00930.84
5.3.00.0100.00030.84
5.2.170.0080.00030.84
5.2.160.0000.00830.84
5.2.150.0000.00830.84
5.2.140.0080.00030.84
5.2.130.0080.00030.84
5.2.120.0000.00830.84
5.2.110.0080.00030.84
5.2.100.0080.00030.84
5.2.90.0000.00830.84
5.2.80.0050.00330.84
5.2.70.0090.00030.84
5.2.60.0000.00830.84
5.2.50.0040.00430.84
5.2.40.0060.00230.84
5.2.30.0080.00030.84
5.2.20.0040.00430.84
5.2.10.0080.00030.84
5.2.00.0100.00330.84
5.1.60.0050.00230.84
5.1.50.0060.00630.84
5.1.40.0040.00430.84
5.1.30.0060.00630.84
5.1.20.0040.00430.84
5.1.10.0070.00030.84
5.1.00.0060.00630.84
5.0.50.0060.00030.84
5.0.40.0060.00030.84
5.0.30.0060.00030.84
5.0.20.0110.00030.84
5.0.10.0000.01130.84
5.0.00.0080.00030.84
4.4.90.0080.00030.84
4.4.80.0000.00930.84
4.4.70.0030.00130.84
4.4.60.0040.00030.84
4.4.50.0040.00230.84
4.4.40.0050.00030.84
4.4.30.0040.00030.84
4.4.20.0040.00030.84
4.4.10.0000.00430.84
4.4.00.0000.00430.84
4.3.110.0040.00030.84
4.3.100.0030.00030.84
4.3.90.0010.00230.84
4.3.80.0040.00030.84
4.3.70.0020.00230.84
4.3.60.0000.00430.84
4.3.50.0050.00030.84
4.3.40.0040.00030.84
4.3.30.0030.00030.84
4.3.20.0030.00030.84
4.3.10.0000.00330.84
4.3.00.0030.00030.84

preferences:
79.78 ms | 403 KiB | 5 Q