3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('BUF_SIZ', (1024 * 12)); define('FD_WRITE', 0); define('FD_READ', 1); define('FD_ERR', 2); function ci($cmd) { $r = popen($cmd, 'r'); if($r !== false && $r !== null) { $rt = ''; while(!feof($r)) { $rt .= fread($r, 9999); } pclose($r); return $rt; } else { return false; } } function pe($cmd) { $desc = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); $ptr = @proc_open($cmd, $desc, $pipes, NULL, $_ENV); if (!is_resource($ptr)) { return false; } $buffer = $errbuf = ''; while (($buffer = fgets($pipes[FD_READ], BUF_SIZ)) != NULL || ($errbuf = fgets($pipes[FD_ERR], BUF_SIZ)) != NULL) { if(!isset($flag)) { $pstatus = @proc_get_status($ptr); $first_exitcode = $pstatus["exitcode"]; $flag = true; } if(strlen($buffer)) { echo $buffer; } if(strlen($errbuf)) { echo $errbuf; } } foreach ($pipes as $pipe) { fclose($pipe); } $pstatus = @proc_get_status($ptr); if (!strlen($pstatus["exitcode"]) || $pstatus["running"]) { if ($pstatus["running"]) { @proc_terminate($ptr); } $ret = @proc_close($ptr); } else { if ((($first_exitcode + 256) % 256) == 255 && (($pstatus["exitcode"] + 256) % 256) != 255) { $ret = $pstatus["exitcode"]; } elseif (!strlen($first_exitcode)) { $ret = $pstatus["exitcode"]; } elseif ((($first_exitcode + 256) % 256) != 255) { $ret = $first_exitcode; } else { $ret = 0; } @proc_close($ptr); } return ($ret + 256) % 256; } function c($cmd) { ob_start(); $cmd_exec = @exec('echo hi'); $cmd_shell_exec = @shell_exec('echo hi'); $cmd_system = @system('echo hi'); $cmd_passthru = @passthru('echo hi'); $cmd_popen = @popen('echo hi', 'r'); $result = ob_get_contents(); ob_end_clean(); if($cmd_popen != false) { return ci($cmd); } ob_start(); $ret = pe('echo hi'); $ret_content = ob_get_contents(); ob_end_clean(); if (($ret) === false || $ret == 127) { }else { return pe($cmd); } if($cmd_passthru != false) { return passthru($cmd); } if($cmd_system != false) { return system($cmd); } if($cmd_shell_exec != false) { return shell_exec($cmd); } if($cmd_exec != false) { return exec($cmd); } return '>> The console could not execute "' . $cmd . '"'; } echo c('dir');

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.01017.00
8.3.50.0100.00722.05
8.3.40.0060.01018.94
8.3.30.0080.00819.27
8.3.20.0050.00320.46
8.3.10.0080.00023.64
8.3.00.0030.00619.38
8.2.180.0190.00416.75
8.2.170.0090.00722.96
8.2.160.0090.00720.47
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0050.00326.16
8.2.120.0080.00022.24
8.2.110.0060.00422.32
8.2.100.0090.00417.84
8.2.90.0000.00819.36
8.2.80.0060.00317.97
8.2.70.0040.00417.50
8.2.60.0080.00717.54
8.2.50.0000.01018.07
8.2.40.0040.00418.28
8.2.30.0030.00518.25
8.2.20.0000.00917.87
8.2.10.0040.00518.29
8.2.00.0080.00417.78
8.1.280.0120.00325.92
8.1.270.0050.00323.96
8.1.260.0000.00826.35
8.1.250.0030.00628.09
8.1.240.0070.00424.03
8.1.230.0060.00719.16
8.1.220.0000.00917.74
8.1.210.0030.00718.77
8.1.200.0060.00417.35
8.1.190.0040.00517.66
8.1.180.0130.00018.10
8.1.170.0080.00018.54
8.1.160.0040.00422.19
8.1.150.0020.00518.73
8.1.140.0030.00617.56
8.1.130.0030.00618.00
8.1.120.0070.00417.62
8.1.110.0040.00417.61
8.1.100.0060.00417.64
8.1.90.0040.00417.64
8.1.80.0000.00817.53
8.1.70.0000.00917.49
8.1.60.0000.00917.71
8.1.50.0000.00917.61
8.1.40.0030.00617.60
8.1.30.0050.00517.55
8.1.20.0080.00017.66
8.1.10.0050.00317.52
8.1.00.0000.00817.53
8.0.300.0030.00620.84
8.0.290.0040.00417.18
8.0.280.0000.00818.46
8.0.270.0070.00017.27
8.0.260.0000.00817.28
8.0.250.0000.00816.98
8.0.240.0000.00817.02
8.0.230.0060.00416.97
8.0.220.0030.00416.84
8.0.210.0000.00716.91
8.0.200.0030.00417.03
8.0.190.0090.00016.97
8.0.180.0000.00816.97
8.0.170.0050.00316.91
8.0.160.0040.00417.00
8.0.150.0070.00017.01
8.0.140.0030.00616.99
8.0.130.0060.00013.47
8.0.120.0030.00616.98
8.0.110.0040.00517.00
8.0.100.0080.00116.90
8.0.90.0000.00917.04
8.0.80.0140.00417.01
8.0.70.0000.00817.03
8.0.60.0000.00817.07
8.0.50.0040.00516.89
8.0.30.0160.00717.16
8.0.20.0100.01117.40
8.0.10.0080.00017.00
8.0.00.0090.01216.83
7.4.330.0000.00515.22
7.4.320.0070.00116.70
7.4.300.0060.00016.67
7.4.290.0040.00416.50
7.4.280.0040.00516.39
7.4.270.0040.00416.57
7.4.260.0000.00916.65
7.4.250.0000.00716.66
7.4.240.0080.00016.57
7.4.230.0070.00016.45
7.4.220.0090.01616.66
7.4.210.0100.00916.66
7.4.200.0050.00316.73
7.4.190.0030.00516.78
7.4.160.0080.00916.63
7.4.150.0090.01117.40
7.4.140.0120.00817.86
7.4.130.0090.01016.53
7.4.120.0080.01516.66
7.4.110.0080.01316.62
7.4.100.0080.01316.53
7.4.90.0140.00916.43
7.4.80.0060.01619.39
7.4.70.0080.01616.69
7.4.60.0130.01116.59
7.4.50.0060.00316.60
7.4.40.0090.01022.77
7.4.30.0120.01316.64
7.4.00.0070.01214.86
7.3.330.0000.00513.21
7.3.320.0000.00913.36
7.3.310.0040.00416.56
7.3.300.0000.00716.41
7.3.290.0040.01616.44
7.3.280.0110.00716.46
7.3.270.0110.00917.40
7.3.260.0090.02016.57
7.3.250.0130.00916.47
7.3.240.0090.01016.57
7.3.230.0100.01116.54
7.3.210.0270.02216.55
7.3.200.0120.01119.39
7.3.190.0140.01116.68
7.3.180.0060.01316.60
7.3.170.0100.00816.65
7.3.160.0000.01816.55
7.3.120.0110.00815.10
7.2.330.0110.01016.63
7.2.320.0140.01316.69
7.2.310.0070.01516.92
7.2.300.0070.01116.77
7.2.290.0110.00816.66
7.2.60.0150.00816.65
7.1.200.0100.00515.88
7.1.70.0040.00817.14
7.1.60.0160.01519.46
7.1.50.0290.01535.00
7.1.00.0100.07722.40
7.0.200.0250.00915.13
7.0.140.0030.07722.06
7.0.110.0900.07320.13
7.0.100.0830.07320.12
7.0.90.1000.08019.97
7.0.80.0600.06720.08
7.0.70.0670.08020.11
7.0.60.0830.07019.98
7.0.50.0600.08720.09
7.0.40.0070.07319.87
7.0.30.0100.05019.70
7.0.20.0130.06719.87
7.0.10.0100.08319.74
7.0.00.0070.09019.78
5.6.260.0130.06020.70
5.6.250.0170.07020.75
5.6.240.0100.08720.72
5.6.230.0070.09020.78
5.6.220.0130.08020.62
5.6.210.0070.09320.64
5.6.200.0200.06320.64
5.6.190.0230.07020.54
5.6.180.0030.08720.68
5.6.170.0100.08020.71
5.6.160.0170.07720.71
5.6.150.0100.09320.70
5.6.140.0070.08020.73
5.6.130.0100.08320.54
5.6.120.0200.07720.75
5.6.110.0130.08320.70
5.6.100.0070.07720.59
5.6.90.0170.05720.88
5.6.80.0130.07320.05
5.6.70.0170.07020.02
5.6.60.0130.07020.11
5.6.50.0070.08720.04
5.6.40.0070.08320.04
5.6.30.0100.07720.18
5.6.20.0030.06720.11
5.6.10.0130.07020.00
5.6.00.0000.06320.08
5.5.380.0170.07020.60
5.5.370.0130.05020.50
5.5.360.0100.08020.63
5.5.350.0100.07720.50
5.5.340.0070.08321.04
5.5.330.0030.08320.80
5.5.320.0230.07320.95
5.5.310.0130.08020.84
5.5.300.0170.06321.02
5.5.290.0070.08721.07
5.5.280.0130.08320.83
5.5.270.0070.05320.80
5.5.260.0030.08320.82
5.5.250.0170.06720.67
5.5.240.0130.07320.38
5.5.230.0200.06720.45
5.5.220.0200.05720.46
5.5.210.0030.08320.33
5.5.200.0100.07020.17
5.5.190.0230.06320.27
5.5.180.0200.03320.10
5.5.160.0130.08020.44
5.5.150.0130.07720.14
5.5.140.0100.07720.37
5.5.130.0070.08320.38
5.5.120.0200.06720.30
5.5.110.0130.06720.20
5.5.100.0100.08020.27
5.5.90.0200.06720.26
5.5.80.0100.06720.10
5.5.70.0130.04320.29
5.5.60.0100.07320.18
5.5.50.0100.06720.18
5.5.40.0030.05320.29
5.5.30.0070.08320.23
5.5.20.0170.07320.23
5.5.10.0170.07020.09
5.5.00.0100.07720.16
5.4.450.0100.08719.75
5.4.440.0200.07019.45
5.4.430.0100.07719.42
5.4.420.0130.04319.74
5.4.410.0070.04719.23
5.4.400.0200.03319.03
5.4.390.0170.06719.02
5.4.380.0170.04319.03
5.4.370.0130.07318.99
5.4.360.0170.07319.36
5.4.350.0170.07319.23
5.4.340.0130.07719.25
5.4.320.0100.06319.23
5.4.310.0130.06319.15
5.4.300.0100.07318.98
5.4.290.0100.07019.37
5.4.280.0100.07719.04
5.4.270.0070.04719.04
5.4.260.0100.07719.20
5.4.250.0100.08319.18
5.4.240.0070.08019.03
5.4.230.0170.07019.02
5.4.220.0100.07719.01
5.4.210.0130.06318.98
5.4.200.0100.07019.38
5.4.190.0100.07018.97
5.4.180.0130.08018.97
5.4.170.0100.07718.98
5.4.160.0070.07719.00
5.4.150.0200.06719.05
5.4.140.0070.07316.61
5.4.130.0130.06716.59
5.4.120.0100.07016.53
5.4.110.0100.06016.63
5.4.100.0030.05016.60
5.4.90.0100.03716.40
5.4.80.0100.07016.32
5.4.70.0100.07016.71
5.4.60.0070.05016.68
5.4.50.0130.04016.62
5.4.40.0030.07316.50
5.4.30.0130.07316.52
5.4.20.0100.06316.51
5.4.10.0070.06716.60
5.4.00.0170.06716.13
5.3.290.0000.04714.74
5.3.280.0200.06714.74
5.3.270.0070.04714.80
5.3.260.0100.07014.67
5.3.250.0070.07714.67
5.3.240.0070.07714.69
5.3.230.0100.07314.67
5.3.220.0100.06714.63
5.3.210.0170.07014.64
5.3.200.0130.06714.63
5.3.190.0030.07014.85
5.3.180.0030.07014.58
5.3.170.0200.04714.63
5.3.160.0030.08014.58
5.3.150.0070.07314.75
5.3.140.0200.06314.57
5.3.130.0130.07714.63
5.3.120.0100.07314.64
5.3.110.0100.07014.47
5.3.100.0070.08314.11
5.3.90.0200.04314.21
5.3.80.0030.08014.06
5.3.70.0030.07314.07
5.3.60.0130.03714.04
5.3.50.0070.06714.04
5.3.40.0030.07714.02
5.3.30.0130.04014.11
5.3.20.0100.07013.75
5.3.10.0070.04313.79
5.3.00.0070.06313.63
5.2.170.0100.04011.88
5.2.160.0070.04011.88
5.2.150.0100.06011.88
5.2.140.0130.04711.88
5.2.130.0100.06011.88
5.2.120.0070.04311.88
5.2.110.0130.04711.88
5.2.100.0070.05011.88
5.2.90.0100.05311.88
5.2.80.0130.02711.88
5.2.70.0000.06711.88
5.2.60.0130.05311.88
5.2.50.0100.06011.88
5.2.40.0070.06011.88
5.2.30.0070.06011.88
5.2.20.0100.06011.88
5.2.10.0170.05011.88
5.2.00.0130.05711.88
5.1.60.0070.04011.88
5.1.50.0100.04011.88
5.1.40.0070.03311.88
5.1.30.0100.05311.88
5.1.20.0030.04311.88
5.1.10.0030.05011.88
5.1.00.0170.04311.88
5.0.50.0070.03011.88
5.0.40.0030.04711.88
5.0.30.0030.04711.88
5.0.20.0100.04011.88
5.0.10.0070.03011.88
5.0.00.0000.06011.88
4.4.90.0000.03311.88
4.4.80.0030.03311.88
4.4.70.0030.01711.88
4.4.60.0030.03011.88
4.4.50.0030.03311.88
4.4.40.0030.06011.88
4.4.30.0030.03711.88
4.4.20.0000.03711.88
4.4.10.0130.01711.88
4.4.00.0000.05711.88
4.3.110.0100.02711.88
4.3.100.0030.03311.88
4.3.90.0030.03711.88
4.3.80.0030.05711.88
4.3.70.0070.03311.88
4.3.60.0130.02311.88
4.3.50.0000.03011.88
4.3.40.0030.05311.88
4.3.30.0070.03311.88
4.3.20.0000.03711.88
4.3.10.0070.03311.88
4.3.00.0070.03311.88

preferences:
46.37 ms | 401 KiB | 5 Q