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 = _js_enc_value($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 = "@[\x08-x010\x0c\x0d\\\\\"'/]|([ -!#-&(-.])++@"; 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], "\f\n\r\t\"'/"); } } } $str = ''; for ($i=0;$i<=32;$i++) { $str .= chr($i); } $str = chr(127); var_dump(json_encode("\x7f\xc0\x80"));

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.0110.00416.75
8.3.50.0130.00721.95
8.3.40.0140.00718.75
8.3.30.0040.01119.21
8.3.20.0080.00020.29
8.3.10.0000.00823.53
8.3.00.0080.00019.13
8.2.180.0110.00718.31
8.2.170.0090.00622.96
8.2.160.0140.00020.38
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00422.25
8.2.110.0030.00622.13
8.2.100.0100.00317.91
8.2.90.0040.00419.22
8.2.80.0000.00817.97
8.2.70.0040.00417.75
8.2.60.0000.00818.05
8.2.50.0000.00918.07
8.2.40.0030.00520.01
8.2.30.0080.00018.25
8.2.20.0040.00417.87
8.2.10.0060.00318.18
8.2.00.0000.00817.67
8.1.280.0070.00725.92
8.1.270.0000.01223.99
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0040.00423.90
8.1.230.0070.00419.10
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0090.00317.48
8.1.190.0030.00717.23
8.1.180.0000.00918.10
8.1.170.0050.00518.55
8.1.160.0000.00822.07
8.1.150.0030.00618.63
8.1.140.0040.00417.51
8.1.130.0000.00717.83
8.1.120.0050.00317.43
8.1.110.0030.00817.53
8.1.100.0080.00017.54
8.1.90.0070.00017.58
8.1.80.0000.00717.59
8.1.70.0000.00717.38
8.1.60.0030.00517.66
8.1.50.0050.00317.56
8.1.40.0050.00217.57
8.1.30.0040.00417.45
8.1.20.0030.00617.76
8.1.10.0030.00617.54
8.1.00.0000.00917.48
8.0.300.0040.00418.77
8.0.290.0040.00417.18
8.0.280.0000.00718.51
8.0.270.0070.00017.37
8.0.260.0060.00017.23
8.0.250.0000.00717.01
8.0.240.0000.00817.04
8.0.230.0040.00417.00
8.0.220.0070.00016.99
8.0.210.0030.00316.82
8.0.200.0040.00417.03
8.0.190.0050.00316.91
8.0.180.0000.00716.88
8.0.170.0000.00817.03
8.0.160.0070.00016.96
8.0.150.0040.00416.87
8.0.140.0000.00716.87
8.0.130.0030.00313.41
8.0.120.0040.00416.81
8.0.110.0000.00717.01
8.0.100.0070.00016.78
8.0.90.0040.00417.00
8.0.80.0090.01216.88
8.0.70.0000.00716.74
8.0.60.0070.00016.89
8.0.50.0000.00716.99
8.0.30.0070.01217.20
8.0.20.0080.01117.40
8.0.10.0070.00017.03
8.0.00.0110.00716.85
7.4.330.0020.00215.02
7.4.320.0000.00716.56
7.4.300.0000.00816.57
7.4.290.0070.00016.65
7.4.280.0000.00716.41
7.4.270.0000.00716.58
7.4.260.0040.00416.70
7.4.250.0080.00016.54
7.4.240.0030.00516.50
7.4.230.0070.00016.46
7.4.220.0120.00316.46
7.4.210.0050.01216.55
7.4.200.0050.00316.39
7.4.190.0070.00016.67
7.4.160.0060.00916.50
7.4.150.0140.01017.40
7.4.140.0100.00817.86
7.4.130.0050.01316.60
7.4.120.0130.00716.51
7.4.110.0120.00816.66
7.4.100.0120.00616.62
7.4.90.0080.00816.57
7.4.80.0070.01019.39
7.4.70.0080.01016.46
7.4.60.0100.00616.58
7.4.50.0060.00316.41
7.4.40.0040.01516.49
7.4.30.0060.00916.42
7.4.10.0070.01114.87
7.4.00.0030.01314.91
7.3.330.0000.00513.33
7.3.320.0000.00513.36
7.3.310.0000.00816.31
7.3.300.0070.00016.36
7.3.290.0060.00916.30
7.3.280.0110.00616.39
7.3.270.0070.01117.40
7.3.260.0150.00316.29
7.3.250.0080.00816.47
7.3.240.0090.00616.71
7.3.230.0120.00616.39
7.3.210.0120.00616.59
7.3.200.0100.01319.39
7.3.190.0070.01416.55
7.3.180.0070.01716.45
7.3.170.0060.01416.48
7.3.160.0130.00316.61
7.3.130.0030.00914.79
7.3.120.0110.00515.17
7.3.110.0130.00615.07
7.3.100.0060.00615.15
7.3.90.0100.00314.83
7.3.80.0030.00814.85
7.3.70.0040.00814.82
7.3.60.0070.00714.98
7.3.50.0120.00414.91
7.3.40.0110.00414.98
7.3.30.0070.00714.85
7.3.20.0030.00916.73
7.3.10.0060.00616.73
7.3.00.0000.01316.74
7.2.330.0100.00716.66
7.2.320.0110.01116.80
7.2.310.0110.00716.70
7.2.300.0060.00916.50
7.2.290.0060.01716.81
7.2.260.0120.00615.10
7.2.250.0070.01014.89
7.2.240.0140.00015.18
7.2.230.0110.00414.98
7.2.220.0000.01815.11
7.2.210.0030.01014.93
7.2.200.0040.00815.14
7.2.190.0060.00315.11
7.2.180.0080.00814.73
7.2.170.0100.00714.76
7.2.160.0060.00914.88
7.2.150.0090.00616.82
7.2.140.0060.01016.73
7.2.130.0030.01217.06
7.2.120.0070.00717.00
7.2.110.0030.00917.03
7.2.100.0060.00916.98
7.2.90.0070.01016.86
7.2.80.0030.00717.10
7.2.70.0030.01716.77
7.2.60.0100.00316.92
7.2.50.0070.01016.90
7.2.40.0080.00417.00
7.2.30.0070.01116.99
7.2.20.0100.00616.92
7.2.10.0000.01716.96
7.2.00.0080.00718.12
7.1.330.0140.00015.77
7.1.320.0030.01015.95
7.1.310.0090.00015.80
7.1.300.0030.00615.81
7.1.290.0070.00315.94
7.1.280.0110.00415.82
7.1.270.0060.00315.59
7.1.260.0070.00715.88
7.1.250.0070.01015.88
7.1.240.0040.00815.86
7.1.230.0060.00315.81
7.1.220.0070.00715.71
7.1.210.0030.01115.87
7.1.200.0070.01015.91
7.1.190.0060.00915.95
7.1.180.0110.00416.00
7.1.170.0040.01015.54
7.1.160.0100.00315.81
7.1.150.0080.00415.62
7.1.140.0070.00715.98
7.1.130.0090.00615.49
7.1.120.0070.00715.94
7.1.110.0120.00315.65
7.1.100.0060.00816.81
7.1.90.0030.01415.48
7.1.80.0030.01015.85
7.1.70.0040.00716.55
7.1.60.0080.01217.67
7.1.50.0170.00625.33
7.1.40.0040.01215.93
7.1.30.0000.01015.60
7.1.20.0040.00715.63
7.1.10.0040.00715.85
7.1.00.0040.04019.13
7.0.330.0090.00615.54
7.0.320.0070.00715.46
7.0.310.0030.00615.30
7.0.300.0030.01015.65
7.0.290.0030.00915.39
7.0.280.0030.01415.44
7.0.270.0100.00315.41
7.0.260.0060.00615.53
7.0.250.0030.01315.54
7.0.240.0000.00915.58
7.0.230.0110.00315.49
7.0.220.0130.00315.24
7.0.210.0070.00715.33
7.0.200.0030.00815.90
7.0.190.0000.00815.30
7.0.180.0100.00715.52
7.0.170.0100.00315.40
7.0.160.0100.00315.57
7.0.150.0030.00715.23
7.0.140.0050.03818.65
7.0.130.0060.00615.47
7.0.120.0090.00315.61
7.0.110.0000.00915.41
7.0.100.0040.00815.39
7.0.90.0110.03917.58
7.0.80.0050.04317.73
7.0.70.0120.04217.56
7.0.60.0060.02817.67
7.0.50.0040.04417.86
7.0.40.0050.03216.76
7.0.30.0060.03316.78
7.0.20.0020.02816.84
7.0.10.0000.02916.83
7.0.00.0100.02016.65
5.6.400.0060.00314.65
5.6.390.0100.00314.41
5.6.380.0030.01014.43
5.6.370.0060.00314.42
5.6.360.0120.00314.30
5.6.350.0040.01114.14
5.6.340.0040.01514.18
5.6.330.0060.00914.48
5.6.320.0090.00014.28
5.6.310.0090.00314.13
5.6.300.0090.00314.54
5.6.290.0100.00314.13
5.6.280.0020.04117.66
5.6.270.0110.00414.38
5.6.260.0040.00714.55
5.6.250.0040.00714.38
5.6.240.0060.03017.36
5.6.230.0050.02817.40
5.6.220.0060.04617.46
5.6.210.0020.03617.38
5.6.200.0080.04817.66
5.6.190.0070.04717.63
5.6.180.0030.03117.70
5.6.170.0050.02317.71
5.6.160.0110.01517.67
5.6.150.0050.02517.69
5.6.140.0020.02717.65
5.6.130.0070.03217.67
5.6.120.0030.04417.67
5.6.110.0070.02217.85
5.6.100.0040.02117.66
5.6.90.0030.02717.70
5.6.80.0020.02717.51
5.6.70.0120.02117.27
5.6.60.0110.02317.20
5.6.50.0080.02817.21
5.6.40.0020.02517.25
5.6.30.0030.02317.38
5.6.20.0040.02117.30
5.6.10.0020.02117.43
5.6.00.0010.03117.39
5.5.380.0130.03817.43
5.5.370.0050.04717.27
5.5.360.0060.03317.21
5.5.350.0030.04717.62
5.5.340.0110.04217.57
5.5.330.0070.04517.38
5.5.320.0070.03417.67
5.5.310.0110.02817.65
5.5.300.0050.03017.67
5.5.290.0070.02717.44
5.5.280.0070.03317.53
5.5.270.0030.02517.42
5.5.260.0100.04017.51
5.5.250.0070.02017.33
5.5.240.0010.02317.27
5.5.230.0030.02317.24
5.5.220.0050.02717.28
5.5.210.0090.02117.35
5.5.200.0050.03017.16
5.5.190.0120.02817.18
5.5.180.0080.02017.33
5.5.170.0110.00314.18
5.5.160.0050.04217.22
5.5.150.0100.04117.15
5.5.140.0070.01717.17
5.5.130.0030.02217.11
5.5.120.0110.01917.36
5.5.110.0000.02617.19
5.5.100.0130.03617.23
5.5.90.0110.03817.15
5.5.80.0110.03817.21
5.5.70.0130.04116.95
5.5.60.0170.03016.93
5.5.50.0120.04017.07
5.5.40.0080.02817.23
5.5.30.0130.02317.14
5.5.20.0050.04317.00
5.5.10.0090.04017.13
5.5.00.0050.02816.96
5.4.450.0030.02315.52
5.4.440.0030.03315.46
5.4.430.0020.03815.43
5.4.420.0050.02015.50
5.4.410.0020.02015.49
5.4.400.0020.02115.40
5.4.390.0070.01815.27
5.4.380.0080.01715.34
5.4.370.0050.02015.35
5.4.360.0020.02315.34
5.4.350.0030.02015.37
5.4.340.0010.03315.35
5.4.330.0000.00611.66
5.4.320.0050.02815.35
5.4.310.0050.03615.40
5.4.300.0020.02215.43
5.4.290.0020.02515.39
5.4.280.0050.01815.26
5.4.270.0020.01915.35
5.4.260.0050.04215.39
5.4.250.0050.03115.30
5.4.240.0050.04315.34
5.4.230.0060.03915.35
5.4.220.0110.03315.43
5.4.210.0040.03215.28
5.4.200.0000.02815.25
5.4.190.0050.03915.27
5.4.180.0040.03115.44
5.4.170.0080.03615.34
5.4.160.0020.04015.34
5.4.150.0050.03715.40
5.4.140.0080.03214.04
5.4.130.0080.01814.06
5.4.120.0070.02914.07
5.4.110.0060.03714.05
5.4.100.0030.02514.05
5.4.90.0090.02514.03
5.4.80.0110.03213.98
5.4.70.0070.01913.98
5.4.60.0090.03913.99
5.4.50.0120.03314.07
5.4.40.0030.03414.06
5.4.30.0020.03713.99
5.4.20.0080.02314.05
5.4.10.0030.04113.95
5.4.00.0000.04313.63
5.3.290.0050.03013.22
5.3.280.0030.04513.19
5.3.270.0100.03513.14
5.3.260.0030.04013.13
5.3.250.0090.03013.17
5.3.240.0030.03713.13
5.3.230.0000.03713.19
5.3.220.0070.03713.13
5.3.210.0060.04413.17
5.3.200.0020.02713.13
5.3.190.0020.02413.09
5.3.180.0030.04313.10
5.3.170.0070.03513.10
5.3.160.0060.03813.16
5.3.150.0040.04113.18
5.3.140.0080.03313.13
5.3.130.0010.03113.18
5.3.120.0050.04313.13
5.3.110.0070.03713.11
5.3.100.0080.02312.92
5.3.90.0020.04012.88
5.3.80.0080.03712.92
5.3.70.0060.03012.90
5.3.60.0070.03512.82
5.3.50.0050.03912.81
5.3.40.0020.04112.87
5.3.30.0070.03512.83
5.3.20.0060.03412.72
5.3.10.0030.03812.66
5.3.00.0050.03512.67
5.2.170.0030.06711.32
5.2.160.0030.05011.20
5.2.150.0070.06011.25
5.2.140.0000.06711.16
5.2.130.0030.06311.13
5.2.120.0100.05311.03
5.2.110.0070.03010.99
5.2.100.0100.05311.27
5.2.90.0100.05711.19
5.2.80.0030.05011.03
5.2.70.0100.05711.17
5.2.60.0070.04711.15
5.2.50.0030.04310.92
5.2.40.0030.03010.96
5.2.30.0030.06010.99
5.2.20.0030.06011.04
5.2.10.0070.02711.02
5.2.00.0070.05310.84
5.1.60.0070.05010.13
5.1.50.0070.05010.05
5.1.40.0130.03710.01
5.1.30.0070.05710.43
5.1.20.0000.05310.45
5.1.10.0030.04310.11
5.1.00.0070.05710.10
5.0.50.0070.0438.68
5.0.40.0030.0478.29
5.0.30.0030.0678.16
5.0.20.0070.0408.09
5.0.10.0030.0478.10
5.0.00.0030.0608.20
4.4.90.0000.0237.29
4.4.80.0100.0207.29
4.4.70.0000.0377.29
4.4.60.0000.0277.29
4.4.50.0000.0177.29
4.4.40.0000.0337.29
4.4.30.0070.0307.29
4.4.20.0000.0377.29
4.4.10.0000.0407.29
4.4.00.0030.0437.29
4.3.110.0100.0307.29
4.3.100.0030.0307.29
4.3.90.0070.0337.29
4.3.80.0070.0577.29
4.3.70.0030.0337.29
4.3.60.0030.0237.29
4.3.50.0000.0377.29
4.3.40.0130.0277.29
4.3.30.0000.0307.29
4.3.20.0030.0337.29
4.3.10.0000.0407.29
4.3.00.0030.0307.29

preferences:
38.27 ms | 401 KiB | 5 Q