3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str="æøå\x01"; var_dump(["str"=>$str,"escapeshellarg"=>escapeshellarg($str), "quoteshellarg"=>quoteshellarg($str)]); /** * quotes shell arguments * (doing a better job than escapeshellarg) * * @param string $arg * @throws UnexpectedValueException if $arg contains null bytes * @return string */ function quoteshellarg(string $arg): string { if (PHP_OS_FAMILY === 'Linux') { // PHP's built-in escapeshellarg() for linux is garbage, corrupting-or-stripping UTF-8 unicode characters like "æøå" // and stripping non-printable characters like \x01 // while single-quoted shell arguments in Linux are binary safe execpt for 2 bytes: \x00 and \x27 // to prevent corruption of UTF-8 characters, we implement our own shell argument quoting for Linux. if (false !== strpos($arg, "\x00")) { throw new UnexpectedValueException('linux shell arguments cannot contain null bytes!'); } return "'" . strtr($arg, array("'" => "'\\''")) . "'"; } // fallback to the php built-in function return escapeshellarg($arg); }

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.20.0110.00720.45
8.4.10.0000.00922.03
8.3.150.0130.00616.65
8.3.140.0070.01317.34
8.3.130.0060.00318.46
8.3.120.0050.00518.98
8.3.110.0030.00620.94
8.3.100.0090.00024.06
8.3.90.0000.00826.77
8.3.80.0030.00616.71
8.3.70.0070.00716.58
8.3.60.0160.00618.43
8.3.50.0070.01018.38
8.3.40.0140.00018.84
8.3.30.0070.00718.66
8.3.20.0070.00024.18
8.3.10.0070.00024.66
8.3.00.0040.00426.16
8.2.270.0090.00917.15
8.2.260.0110.00716.57
8.2.250.0120.00316.60
8.2.240.0030.00517.16
8.2.230.0080.00022.58
8.2.220.0100.01037.54
8.2.210.0080.00026.77
8.2.200.0030.00616.63
8.2.190.0140.00716.75
8.2.180.0120.00925.92
8.2.170.0120.00319.21
8.2.160.0100.00322.96
8.2.150.0060.00325.66
8.2.140.0060.00324.66
8.2.130.0060.00326.16
8.2.120.0090.00019.66
8.2.110.0070.00319.16
8.2.100.0070.00418.04
8.2.90.0040.00418.16
8.2.80.0080.00017.97
8.2.70.0060.00317.49
8.2.60.0030.00518.05
8.2.50.0000.00818.07
8.2.40.0030.00618.22
8.2.30.0040.00418.03
8.2.20.0030.00520.48
8.2.10.0040.00418.16
8.2.00.0030.00519.17
8.1.310.0140.00318.29
8.1.300.0040.00817.43
8.1.290.0030.00630.84
8.1.280.0140.00025.92
8.1.270.0100.01024.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00422.25
8.1.230.0030.00820.90
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0060.00317.36
8.1.190.0030.00517.23
8.1.180.0030.00518.10
8.1.170.0000.00818.43
8.1.160.0000.00820.70
8.1.150.0030.00618.63
8.1.140.0050.00317.37
8.1.130.0050.00218.75
8.1.120.0000.00717.45
8.1.110.0040.00417.49
8.1.100.0040.00417.48
8.1.90.0070.00017.31
8.1.80.0070.00317.43
8.1.70.0120.00517.26
8.1.60.0160.00317.41
8.1.50.0140.00317.42
8.1.40.0140.00317.39
8.1.30.0090.00917.60
8.1.20.0080.01017.54
8.1.10.0140.00517.39
8.1.00.0160.00017.35
8.0.300.0000.00720.08
8.0.290.0070.00016.75
8.0.280.0000.00718.40
8.0.270.0050.00316.87
8.0.260.0040.00418.43
8.0.250.0000.00817.00
8.0.240.0000.00716.98
8.0.230.0080.00016.90
8.0.220.0040.00416.89
8.0.210.0080.00016.99
8.0.200.0060.00316.88
8.0.190.0030.00616.66
8.0.180.0060.00316.86
8.0.170.0030.00716.95
8.0.160.0000.01116.88
8.0.150.0070.00316.82
8.0.140.0070.00416.84
8.0.130.0100.00016.71
8.0.120.0060.00616.90
8.0.110.0070.00716.94
8.0.100.0120.00316.81
8.0.90.0080.00816.91
8.0.80.0090.00616.93
8.0.70.0150.00016.91
8.0.60.0150.00016.75
8.0.50.0110.00416.80
8.0.30.0050.01016.83
8.0.20.0090.00616.93
8.0.10.0100.00316.95
7.4.330.0000.00615.55
7.4.320.0030.00316.41
7.4.300.0090.00616.45
7.4.290.0120.00416.36
7.4.280.0050.01116.54
7.4.270.0100.00716.59
7.4.260.0160.00016.58
7.4.250.0030.00616.43
7.4.240.0000.01116.34
7.4.230.0060.01116.36
7.4.220.0070.00716.47
7.4.210.0070.00716.39
7.4.200.0140.00016.37
7.4.190.0110.00416.52
7.4.180.0150.00016.46
7.4.160.0080.00016.52
7.4.150.0030.00316.59
7.4.140.0040.00416.39
7.4.130.0040.00416.43
7.4.120.0030.00316.48
7.4.110.0070.00016.32
7.4.100.0000.00716.59
7.4.90.0060.00316.45
7.4.80.0090.00016.53
7.4.70.0030.00316.57
7.4.60.0070.00316.39
7.4.50.0110.00016.31
7.4.40.0160.00016.46
7.4.30.0100.00616.48
7.4.20.0080.00516.29
7.4.10.0100.00316.46
7.4.00.0100.00316.46

preferences:
27.83 ms | 403 KiB | 5 Q