3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('json_encode')) { function json_encode($it) { if (!($assoc = is_object($it)) && !is_array($it)) { return _js_enc_value($it); } $i = 0; $it = (array)$it; if (!$assoc) { foreach ($it as $k => $v) { if ($k !== $i) { $assoc = true; break; } $i++; } } $data = array(); foreach ($it as $k => $v) { $v = _js_enc_value($v); if ($assoc) { $k = '"'. addcslashes($k, '"\\') . '"'; $data[] = $k . ':' . $v; } else { $data[] = $v; } } if ($assoc) { $bl = '{'; $br = '}'; } else { $bl = '['; $br = ']'; } return $bl . implode(',', $data) . $br; } function _js_enc_value($value) { switch (true) { case is_array($value): case is_object($value): return json_encode($value); case is_bool($value): return $value ? 'true' : 'false'; case $value === null: case is_resource($value) && _js_error(): return 'null'; case is_string($value): return '"' . _js_uc_esc($value) . '"'; default: return $value; } } function _js_error() { return trigger_error('json_encode(): type is unsupported, encoded as null', E_USER_WARNING); } function _js_uc_esc($value) { $pattern = "@[\r\n\"'/]|([^\x09\x0A\x0D\x20-\x7E]{3})+@"; return preg_replace_callback($pattern, '_js_uc_esc_cb', $value); } function _js_uc_esc_cb($matches) { switch (true) { case isset($matches[1]): $char = mb_convert_encoding($matches[0], 'UTF-16', 'UTF-8'); $str = ''; $len = strlen($char); for ($i = 0; $i < $len; $i += 2) { $str .= sprintf('\\u%02x%02x', ord($char[$i]), ord($char[$i + 1])); } return $str; default: return addcslashes($matches[0], "\r\n\"'/"); } } } echo json_encode(array('あ'=>'"/'));

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.0070.00716.50
8.3.50.0100.01218.15
8.3.40.0120.00318.70
8.3.30.0130.00318.51
8.3.20.0090.00018.64
8.3.10.0000.00820.48
8.3.00.0080.00019.38
8.2.180.0150.00616.50
8.2.170.0150.00022.96
8.2.160.0040.01120.23
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00420.43
8.2.110.0060.00619.32
8.2.100.0090.00317.78
8.2.90.0030.00619.23
8.2.80.0090.00017.97
8.2.70.0060.00317.50
8.2.60.0000.00917.79
8.2.50.0100.00318.07
8.2.40.0040.00418.03
8.2.30.0060.00318.02
8.2.20.0000.01019.44
8.2.10.0040.00417.67
8.2.00.0050.00217.61
8.1.280.0140.00425.92
8.1.270.0040.00424.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.00921.23
8.1.230.0040.00717.45
8.1.220.0000.00917.74
8.1.210.0030.00618.77
8.1.200.0040.00417.23
8.1.190.0040.00417.22
8.1.180.0050.00318.10
8.1.170.0030.00518.54
8.1.160.0030.00618.88
8.1.150.0050.00318.67
8.1.140.0000.00717.44
8.1.130.0070.00017.73
8.1.120.0030.00817.39
8.1.110.0060.00317.43
8.1.100.0040.00417.34
8.1.90.0000.00717.29
8.1.80.0030.00517.48
8.1.70.0000.00717.49
8.1.60.0030.00517.61
8.1.50.0040.00417.39
8.1.40.0050.00317.48
8.1.30.0090.00017.69
8.1.20.0030.00617.48
8.1.10.0000.00717.53
8.1.00.0000.00817.32
8.0.300.0000.00718.77
8.0.290.0050.00316.75
8.0.280.0000.00718.48
8.0.270.0040.00417.30
8.0.260.0060.00016.80
8.0.250.0000.00716.99
8.0.240.0060.00316.89
8.0.230.0000.00716.82
8.0.220.0050.00316.79
8.0.210.0020.00516.91
8.0.200.0040.00416.84
8.0.190.0080.00016.92
8.0.180.0040.00416.92
8.0.170.0080.00016.94
8.0.160.0080.00016.93
8.0.150.0030.00616.88
8.0.140.0040.00416.88
8.0.130.0030.00313.28
8.0.120.0030.00516.70
8.0.110.0040.00416.92
8.0.100.0030.00516.82
8.0.90.0070.00016.91
8.0.80.0160.00316.87
8.0.70.0000.00716.80
8.0.60.0000.00716.93
8.0.50.0070.00316.90
8.0.30.0100.01017.07
8.0.20.0130.00517.04
8.0.10.0000.00716.91
8.0.00.0070.01416.85
7.4.330.0060.00012.98
7.4.320.0000.00616.69
7.4.300.0030.00316.63
7.4.290.0070.00016.61
7.4.280.0030.00516.61
7.4.270.0040.00416.62
7.4.260.0030.00213.23
7.4.250.0040.00416.36
7.4.240.0020.00516.55
7.4.230.0000.00716.34
7.4.220.0100.01016.45
7.4.210.0120.00916.52
7.4.200.0070.00016.52
7.4.190.0030.00316.55
7.4.160.0040.01716.34
7.4.150.0080.01016.39
7.4.140.0170.00016.40
7.4.130.0150.00416.52
7.4.120.0090.00616.39
7.4.110.0150.00316.55
7.4.100.0060.01216.46
7.4.90.0070.01116.43
7.4.80.0100.00719.39
7.4.70.0120.00616.46
7.4.60.0120.00616.48
7.4.50.0030.00616.26
7.4.40.0060.01016.71
7.4.30.0030.01416.56
7.4.00.0090.00415.24
7.3.330.0000.00513.34
7.3.320.0060.00013.15
7.3.310.0070.00016.11
7.3.300.0000.00616.11
7.3.290.0070.00816.25
7.3.280.0060.01116.28
7.3.270.0110.00716.34
7.3.260.0170.00616.49
7.3.250.0070.01016.48
7.3.240.0030.01316.40
7.3.230.0100.01016.34
7.3.210.0070.01116.16
7.3.200.0120.00316.29
7.3.190.0110.01116.27
7.3.180.0060.01216.23
7.3.170.0160.00416.38
7.3.160.0120.00616.21
7.3.120.0000.01714.62
7.2.330.0100.00716.73
7.2.320.0060.01716.29
7.2.310.0100.01016.30
7.2.300.0040.01316.41
7.2.290.0130.00316.58
7.2.00.0060.00619.01
7.1.100.0000.01117.90
7.1.70.0000.00716.66
7.1.60.0130.01319.31
7.1.50.0060.01516.70
7.1.00.0030.05722.32
7.0.200.0000.00716.86
7.0.140.0030.07322.11
7.0.120.0030.06722.21
7.0.90.0630.08319.99
7.0.80.0600.05019.93
7.0.70.0770.05019.82
7.0.60.0630.08019.75
7.0.50.0670.07020.26
7.0.40.0070.05320.18
7.0.30.0000.08020.05
7.0.20.0100.07720.18
7.0.10.0030.04720.07
7.0.00.0030.05320.16
5.6.280.0130.06321.09
5.6.240.0070.07720.56
5.6.230.0070.07320.69
5.6.220.0100.07020.49
5.6.210.0130.06720.61
5.6.200.0100.07321.07
5.6.190.0200.07021.09
5.6.180.0100.08021.09
5.6.170.0030.08321.08
5.6.160.0100.03021.04
5.6.150.0100.05021.19
5.6.140.0030.04321.03
5.6.130.0000.04720.96
5.6.120.0000.04720.95
5.6.110.0030.04021.04
5.6.100.0030.07021.01
5.6.90.0030.04321.07
5.6.80.0070.03720.36
5.6.70.0070.03720.31
5.6.60.0000.04320.35
5.6.50.0030.04020.52
5.6.40.0000.04320.43
5.6.30.0070.03720.55
5.6.20.0070.03720.30
5.6.10.0100.04320.44
5.6.00.0070.03720.44
5.5.380.0100.07320.53
5.5.370.0170.07320.32
5.5.360.0130.07320.50
5.5.350.0100.07720.42
5.5.340.0030.04320.84
5.5.330.0030.05020.75
5.5.320.0170.03320.92
5.5.310.0130.07320.78
5.5.300.0030.04020.88
5.5.290.0070.05320.93
5.5.280.0100.03320.77
5.5.270.0070.04320.79
5.5.260.0000.04320.88
5.5.250.0070.05320.70
5.5.240.0030.04020.28
5.5.230.0030.04020.04
5.5.220.0100.03320.19
5.5.210.0030.04020.31
5.5.200.0030.03720.01
5.5.190.0000.04720.10
5.5.180.0030.04020.25
5.5.160.0000.04320.24
5.5.150.0070.04020.14
5.5.140.0000.06020.14
5.5.130.0030.04320.20
5.5.120.0070.03720.00
5.5.110.0030.05320.28
5.5.100.0030.05320.18
5.5.90.0000.04020.02
5.5.80.0030.03720.09
5.5.70.0130.03720.08
5.5.60.0030.04019.94
5.5.50.0100.03720.13
5.5.40.0030.03720.10
5.5.30.0100.03320.11
5.5.20.0000.04019.97
5.5.10.0030.05719.99
5.5.00.0070.07320.12
5.4.450.0030.04019.45
5.4.440.0070.03719.42
5.4.430.0030.04019.45
5.4.420.0000.05719.37
5.4.410.0070.05719.29
5.4.400.0070.03319.18
5.4.390.0030.03719.25
5.4.380.0030.05018.96
5.4.370.0100.03019.05
5.4.360.0000.04019.03
5.4.350.0070.03719.21
5.4.340.0030.03719.20
5.4.320.0100.03019.13
5.4.310.0100.07319.09
5.4.300.0000.04018.94
5.4.290.0100.07019.04
5.4.280.0000.04319.12
5.4.270.0030.06319.20
5.4.260.0030.03719.09
5.4.250.0000.06019.05
5.4.240.0070.03319.13
5.4.230.0070.04018.84
5.4.220.0030.04719.16
5.4.210.0070.03019.13
5.4.200.0070.04318.89
5.4.190.0030.03718.89
5.4.180.0000.05019.17
5.4.170.0030.04019.04
5.4.160.0100.06319.05
5.4.150.0100.06719.01
5.4.140.0070.05316.35
5.4.130.0070.07016.48
5.4.120.0030.04016.46
5.4.110.0100.05716.44
5.4.100.0070.07316.44
5.4.90.0070.07316.45
5.4.80.0030.06716.43
5.4.70.0070.06316.50
5.4.60.0100.06316.43
5.4.50.0070.07316.53
5.4.40.0030.05016.51
5.4.30.0070.06316.42
5.4.20.0130.06316.47
5.4.10.0070.07316.46
5.4.00.0070.07015.87
5.3.290.0000.04014.71
5.3.280.0030.05714.59
5.3.270.0100.04714.77
5.3.260.0000.04314.73
5.3.250.0030.05314.68
5.3.240.0100.07014.66
5.3.230.0030.04014.71
5.3.220.0000.07714.66
5.3.210.0030.07714.68
5.3.200.0030.06714.55
5.3.190.0070.04314.55
5.3.180.0100.04014.65
5.3.170.0070.07014.60
5.3.160.0070.07714.72
5.3.150.0130.06714.73
5.3.140.0070.06314.59
5.3.130.0000.08314.68
5.3.120.0100.04714.62
5.3.110.0030.05714.68
5.3.100.0100.07014.08
5.3.90.0100.07014.13
5.3.80.0030.07014.14
5.3.70.0000.08014.15
5.3.60.0100.07014.14
5.3.50.0130.06013.88
5.3.40.0070.04714.12
5.3.30.0100.05314.04
5.3.20.0030.06013.82
5.3.10.0030.06713.71
5.3.00.0030.07313.72
5.2.170.0100.04011.09
5.2.160.0070.04711.29
5.2.150.0070.05311.08
5.2.140.0030.05011.08
5.2.130.0000.04011.04
5.2.120.0130.05311.24
5.2.110.0000.07011.12
5.2.100.0070.06011.20
5.2.90.0030.06011.13
5.2.80.0100.05711.03
5.2.70.0070.04711.23
5.2.60.0130.05011.08
5.2.50.0030.06311.16
5.2.40.0070.05710.96
5.2.30.0100.06311.06
5.2.20.0000.05311.04
5.2.10.0030.03310.80
5.2.00.0030.05710.68
5.1.60.0070.05010.09
5.1.50.0030.04310.02
5.1.40.0030.0509.84
5.1.30.0000.05010.43
5.1.20.0000.04310.28
5.1.10.0030.0479.95
5.1.00.0000.04310.09
5.0.50.0030.0408.69
5.0.40.0030.0278.31
5.0.30.0030.0378.11
5.0.20.0000.0408.23
5.0.10.0030.0278.21
5.0.00.0030.0478.32
4.4.90.0030.0339.96
4.4.80.0000.0379.96
4.4.70.0030.0376.35
4.4.60.0000.0376.35
4.4.50.0030.0236.35
4.4.40.0030.0406.35
4.4.30.0000.0376.35
4.4.20.0000.0376.35
4.4.10.0100.0276.35
4.4.00.0000.0576.35
4.3.110.0100.0276.35
4.3.100.0000.0336.35
4.3.90.0030.0306.35
4.3.80.0100.0276.35
4.3.70.0000.0236.35
4.3.60.0000.0306.35
4.3.50.0000.0206.35
4.3.40.0030.0276.35
4.3.30.0000.0336.35
4.3.20.0000.0336.35
4.3.10.0000.0376.35
4.3.00.0030.0336.35

preferences:
44.4 ms | 401 KiB | 5 Q