3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CookieCodec { /** * All characters valid in a cookie according to https://tools.ietf.org/html/rfc6265 and we have additionally * removed % (used for escape sequences) and + (which, if not encoded, is interpreted as space in cookies by PHP, * but there's no equivalent built-in JS decoding function, so we escape it to make decoding equivalent in both * cases). */ private const COOKIE_CHARSET = '!#$&\'()*-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~'; public static function encode($string) { $string = (string) $string; $output = ''; for ($i = 0, $m = \strlen($string); $i < $m; $i++) { $char = $string[$i]; if (\strpos(self::COOKIE_CHARSET, $char) === false) { $ord = \ord($char); $code = \strtoupper(\dechex($ord)); $output .= $ord > 15 ? "%$code" : "%0$code"; } else { $output .= $char; } } return $output; } }

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.0080.00816.63
8.3.50.0110.00717.92
8.3.40.0120.00318.84
8.3.30.0190.00018.60
8.3.20.0110.00720.34
8.3.10.0040.00421.77
8.3.00.0060.00319.56
8.2.180.0070.00716.50
8.2.170.0100.00722.96
8.2.160.0070.00718.79
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0000.00820.51
8.2.110.0060.00320.22
8.2.100.0030.00817.72
8.2.90.0000.00818.97
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0040.00417.91
8.2.50.0000.00818.10
8.2.40.0040.00422.33
8.2.30.0020.00519.14
8.2.20.0040.00417.96
8.2.10.0060.00317.94
8.2.00.0040.00417.96
8.1.280.0040.01225.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0090.00020.91
8.1.230.0040.00719.16
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0000.01017.23
8.1.190.0000.00917.10
8.1.180.0040.00418.10
8.1.170.0030.00518.52
8.1.160.0040.00418.89
8.1.150.0040.00418.80
8.1.140.0000.00719.39
8.1.130.0030.00318.78
8.1.120.0000.00717.29
8.1.110.0000.00817.24
8.1.100.0040.00417.30
8.1.90.0070.00017.39
8.1.80.0070.00017.36
8.1.70.0040.00417.29
8.1.60.0040.00417.43
8.1.50.0000.00817.42
8.1.40.0030.00617.25
8.1.30.0040.00417.50
8.1.20.0040.00417.55
8.1.10.0040.00417.43
8.1.00.0030.00617.27
8.0.300.0000.00718.77
8.0.290.0040.00416.63
8.0.280.0030.00318.34
8.0.270.0070.00017.22
8.0.260.0000.00618.69
8.0.250.0000.00616.82
8.0.240.0040.00416.81
8.0.230.0040.00716.81
8.0.220.0030.00316.68
8.0.210.0000.00816.67
8.0.200.0030.00316.88
8.0.190.0050.00316.73
8.0.180.0000.00816.75
8.0.170.0070.00016.89
8.0.160.0000.00816.69
8.0.150.0070.00016.63
8.0.140.0000.00716.64
8.0.130.0000.00513.21
8.0.120.0000.00816.77
8.0.110.0030.00316.67
8.0.100.0040.00416.83
8.0.90.0000.00716.76
8.0.80.0030.01316.76
8.0.70.0000.00716.68
8.0.60.0050.00216.71
8.0.50.0000.00716.66
8.0.30.0060.01016.87
8.0.20.0120.00817.40
8.0.10.0030.00316.85
8.0.00.0070.01116.53
7.4.330.0000.00515.55
7.4.320.0060.00016.35
7.4.300.0060.00016.39
7.4.290.0030.00316.54
7.4.280.0070.00016.41
7.4.270.0030.00316.48
7.4.260.0030.00316.34
7.4.250.0000.00716.32
7.4.240.0070.00016.55
7.4.230.0080.00016.30
7.4.220.0110.00916.50
7.4.210.0040.01216.50
7.4.200.0030.00316.52
7.4.160.0060.01316.26
7.4.150.0120.00617.40
7.4.140.0080.01317.86
7.4.130.0120.00616.48
7.4.120.0130.00916.35
7.4.110.0100.00716.45
7.4.100.0080.00816.34
7.4.90.0120.00616.26
7.4.80.0150.00619.39
7.4.70.0100.01016.35
7.4.60.0120.00616.38
7.4.50.0070.01116.18
7.4.40.0090.00616.27
7.4.30.0100.00616.48
7.4.10.0070.01314.97
7.4.00.0080.01114.74
7.3.330.0050.00013.04
7.3.320.0040.00413.16
7.3.310.0040.00416.24
7.3.300.0070.00016.21
7.3.290.0050.01116.19
7.3.280.0090.00816.18
7.3.270.0150.00917.40
7.3.260.0130.00716.42
7.3.250.0120.00516.32
7.3.240.0120.00616.37
7.3.230.0110.00716.52
7.3.210.0180.00516.31
7.3.200.0100.00716.52
7.3.190.0070.01416.26
7.3.180.0130.00316.43
7.3.170.0060.01016.35
7.3.160.0060.00916.34
7.3.130.0030.01614.73
7.3.120.0080.01014.60
7.3.110.0090.00714.91
7.3.100.0020.01114.54
7.3.90.0020.01114.80
7.3.80.0030.00914.57
7.3.70.0070.00514.58
7.3.60.0070.00514.46
7.3.50.0120.00414.60
7.3.40.0030.00914.67
7.3.30.0070.00714.66
7.3.20.0030.00916.53
7.3.10.0130.00116.47
7.3.00.0100.00816.64
7.2.330.0030.01616.61
7.2.320.0060.01216.52
7.2.310.0090.00916.52
7.2.300.0070.01016.46
7.2.290.0120.00616.59
7.2.260.0040.01414.89
7.2.250.0080.00914.69
7.2.240.0050.01114.89
7.2.230.0070.00915.01
7.2.220.0070.00514.69
7.2.210.0060.00814.65
7.2.200.0060.00614.70
7.2.190.0060.00914.99
7.2.180.0030.01014.82
7.2.170.0060.00514.75
7.2.160.0040.01214.82
7.2.150.0140.00316.52
7.2.140.0110.00716.84
7.2.130.0000.01916.67
7.2.120.0030.00616.68
7.2.110.0060.00916.77
7.2.100.0040.00816.75
7.2.90.0060.00616.83
7.2.80.0080.00416.72
7.2.70.0120.00616.75
7.2.60.0120.00316.49
7.2.50.0100.00316.91
7.2.40.0120.00016.63
7.2.30.0070.00716.90
7.2.20.0030.01016.80
7.2.10.0100.00316.60
7.2.00.0030.00916.77
7.1.330.0060.00815.51
7.1.320.0060.00615.61
7.1.310.0040.01015.50
7.1.300.0070.01015.61
7.1.290.0040.00415.59
7.1.280.0060.00715.60
7.1.270.0050.00915.51
7.1.260.0090.00815.60
7.1.250.0040.01415.63
7.1.240.0120.00015.50
7.1.230.0040.01215.69
7.1.220.0070.01115.46
7.1.210.0030.01315.52
7.1.200.0050.00815.54
7.1.190.0060.01215.74
7.1.180.0040.00815.64
7.1.170.0030.00615.73
7.1.160.0060.00615.52
7.1.150.0080.00815.41
7.1.140.0070.00415.70
7.1.130.0130.00015.42
7.1.120.0000.01415.36
7.1.110.0070.00715.64
7.1.100.0040.01115.55
7.1.90.0070.00715.42
7.1.80.0040.00415.57
7.1.70.0100.00616.30
7.1.60.0150.01225.20
7.1.50.0160.00725.09
7.1.40.0220.01024.86
7.1.30.0110.00825.05
7.1.20.0160.01125.13
7.1.10.0070.01015.92
7.1.00.0090.00616.06
7.0.330.0120.00015.52
7.0.320.0090.00615.16
7.0.310.0060.00615.40
7.0.300.0080.00015.30
7.0.290.0030.01015.24
7.0.280.0100.00315.10
7.0.270.0060.00315.15
7.0.260.0090.00315.25
7.0.250.0030.00615.13
7.0.240.0030.00915.12
7.0.230.0040.00415.49
7.0.220.0070.00415.05
7.0.210.0060.00615.33
7.0.200.0060.01115.98
7.0.190.0060.01015.90
7.0.180.0070.00915.63
7.0.170.0070.00515.83
7.0.160.0040.01015.56
7.0.150.0090.00715.74
7.0.140.0410.00915.63
7.0.130.0060.01115.78
7.0.120.0420.00614.76
7.0.110.0250.01215.61
7.0.100.0070.00915.67
7.0.90.0350.01115.69
7.0.80.0390.01215.64
7.0.70.0410.00414.48
7.0.60.0070.00715.53
7.0.50.0070.00915.66
7.0.40.0020.01314.85
7.0.30.0510.00814.02
7.0.20.0080.00914.84
7.0.10.0090.00514.74
7.0.00.0390.00514.76
5.6.400.0110.00414.00
5.6.390.0000.01414.47
5.6.380.0060.00614.39
5.6.370.0090.00614.20
5.6.360.0070.00314.30
5.6.350.0070.00714.03
5.6.340.0100.00314.00
5.6.330.0050.00514.47
5.6.320.0080.00013.88
5.6.310.0060.00614.12
5.6.300.0070.00314.32
5.6.290.0030.00614.25
5.6.280.0100.00713.89
5.6.270.0120.00614.28
5.6.260.0070.00714.09
5.6.250.0030.00714.21
5.6.240.0070.00714.02
5.6.230.0060.00614.15
5.6.220.0090.00614.23
5.6.210.0040.01114.02
5.6.200.0100.00614.21
5.6.190.0030.00614.04
5.6.180.0140.00013.89
5.6.170.0080.00614.14
5.6.160.0080.00414.07
5.6.150.0120.00314.07
5.6.140.0030.01013.89
5.6.130.0030.01014.03
5.6.120.0130.00314.30
5.6.110.0050.00514.00
5.6.100.0070.00714.05
5.6.90.0030.01314.07
5.6.80.0060.00614.17
5.6.70.0100.00314.02
5.6.60.0110.00314.00
5.6.50.0070.00414.00
5.6.40.0030.00613.88
5.6.30.0050.00513.99
5.6.20.0000.01713.96
5.6.10.0040.01114.12
5.6.00.0070.00714.01

preferences:
56.32 ms | 400 KiB | 5 Q