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], "\x08\x09\x10\x0c\x0d\\\"/"); } } } $str = ''; for ($i=0;$i<=32;$i++) { $str .= chr($i); } $str = chr(127); var_dump(json_encode(array("\xc0\x80" => "hoge")));

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.0100.00716.38
8.3.50.0140.00717.39
8.3.40.0070.00718.67
8.3.30.0150.00318.71
8.3.20.0160.00318.68
8.3.10.0030.00620.59
8.3.00.0090.00019.38
8.2.180.0120.00916.75
8.2.170.0150.00022.96
8.2.160.0140.00021.19
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.36
8.2.110.0060.00321.18
8.2.100.0040.00717.91
8.2.90.0030.00619.22
8.2.80.0070.00019.40
8.2.70.0090.00017.75
8.2.60.0000.00918.03
8.2.50.0060.00318.07
8.2.40.0000.00718.22
8.2.30.0000.00818.22
8.2.20.0050.00217.78
8.2.10.0030.00617.67
8.2.00.0000.00717.62
8.1.280.0100.01025.92
8.1.270.0000.00824.66
8.1.260.0060.00326.35
8.1.250.0000.00828.09
8.1.240.0110.00020.70
8.1.230.0090.00321.09
8.1.220.0060.00317.74
8.1.210.0100.00019.02
8.1.200.0070.00317.48
8.1.190.0040.00417.53
8.1.180.0060.00418.10
8.1.170.0060.00320.74
8.1.160.0030.00618.90
8.1.150.0030.00618.76
8.1.140.0060.00317.56
8.1.130.0000.00717.80
8.1.120.0040.00417.55
8.1.110.0030.00517.47
8.1.100.0000.00917.52
8.1.90.0050.00317.49
8.1.80.0050.00317.58
8.1.70.0050.00217.50
8.1.60.0040.00417.61
8.1.50.0040.00417.46
8.1.40.0000.00817.59
8.1.30.0040.00417.70
8.1.20.0030.00617.76
8.1.10.0050.00317.54
8.1.00.0040.00417.46
8.0.300.0070.00020.01
8.0.290.0040.00416.75
8.0.280.0070.00018.59
8.0.270.0040.00417.20
8.0.260.0030.00316.76
8.0.250.0000.00817.05
8.0.240.0000.00717.01
8.0.230.0040.00416.92
8.0.220.0070.00016.95
8.0.210.0070.00016.87
8.0.200.0040.00416.91
8.0.190.0060.00317.07
8.0.180.0000.00716.87
8.0.170.0030.00616.86
8.0.160.0000.00716.94
8.0.150.0030.00616.92
8.0.140.0050.00516.94
8.0.130.0000.00513.35
8.0.120.0040.00416.97
8.0.110.0000.00716.94
8.0.100.0070.00016.82
8.0.90.0040.00416.84
8.0.80.0060.00917.01
8.0.70.0000.00816.76
8.0.60.0080.00017.01
8.0.50.0050.00316.97
8.0.30.0140.01017.13
8.0.20.0100.00917.02
8.0.10.0040.00417.13
8.0.00.0080.01016.91
7.4.330.0000.00512.95
7.4.320.0060.00016.54
7.4.300.0030.00316.67
7.4.290.0070.00016.71
7.4.280.0040.00416.59
7.4.270.0030.00616.56
7.4.260.0030.00313.25
7.4.250.0050.00316.49
7.4.240.0030.00316.61
7.4.230.0000.00716.69
7.4.220.0130.01016.36
7.4.210.0050.01116.59
7.4.200.0030.00616.39
7.4.190.0030.00316.69
7.4.160.0060.01316.30
7.4.150.0110.00616.50
7.4.140.0070.01216.53
7.4.130.0140.00616.45
7.4.120.0110.00516.61
7.4.110.0070.01016.70
7.4.100.0100.00716.57
7.4.90.0090.00916.63
7.4.80.0090.01419.39
7.4.70.0070.01116.53
7.4.60.0080.01116.68
7.4.50.0030.00316.41
7.4.40.0060.01216.62
7.4.30.0070.01016.49
7.4.00.0000.01614.88
7.3.330.0070.00013.34
7.3.320.0000.00613.31
7.3.310.0050.00216.20
7.3.300.0040.00416.35
7.3.290.0080.00816.26
7.3.280.0080.00716.32
7.3.270.0120.00616.30
7.3.260.0100.01116.60
7.3.250.0130.00916.52
7.3.240.0000.01616.63
7.3.230.0100.00716.68
7.3.210.0090.00916.60
7.3.200.0130.00616.59
7.3.190.0090.01116.59
7.3.180.0030.01316.61
7.3.170.0030.01416.41
7.3.160.0090.01216.21
7.3.120.0100.00714.93
7.2.330.0090.00916.84
7.2.320.0150.00916.59
7.2.310.0070.01116.64
7.2.300.0140.00316.77
7.2.290.0180.00716.51
7.2.00.0070.00719.41
7.1.100.0580.01015.71
7.1.70.0060.00317.13
7.1.60.0030.02219.40
7.1.50.0070.01716.67
7.1.00.0100.05322.33
7.0.200.0210.00714.83
7.0.140.0030.07722.21
7.0.120.0100.06322.06
7.0.110.0100.08019.95
7.0.100.0030.08720.14
7.0.90.0170.05719.98
7.0.80.0100.04720.09
7.0.70.0030.08319.96
7.0.60.0200.07020.08
7.0.50.0070.07720.50
7.0.40.0070.08320.05
7.0.30.0070.05320.16
7.0.20.0070.07719.96
7.0.10.0130.06320.15
7.0.00.0070.08320.04
5.6.280.0030.07321.09
5.6.260.0070.08020.91
5.6.250.0200.07320.68
5.6.240.0130.07720.74
5.6.230.0030.05320.71
5.6.220.0100.06320.86
5.6.210.0100.07720.70
5.6.200.0130.08021.16
5.6.190.0030.09021.30
5.6.180.0070.05021.16
5.6.170.0030.08721.04
5.6.160.0070.04321.16
5.6.150.0130.04021.09
5.6.140.0100.08321.16
5.6.130.0130.07321.16
5.6.120.0170.07320.96
5.6.110.0170.04721.13
5.6.100.0070.05321.30
5.6.90.0170.07020.98
5.6.80.0000.08320.34
5.6.70.0030.08320.47
5.6.60.0100.06720.44
5.6.50.0100.07320.35
5.6.40.0100.08020.52
5.6.30.0130.07320.56
5.6.20.0130.06720.51
5.6.10.0170.07320.56
5.6.00.0130.05720.38
5.5.380.0100.04720.39
5.5.370.0130.08020.58
5.5.360.0070.05020.54
5.5.350.0000.08720.17
5.5.340.0100.07020.98
5.5.330.0070.05020.92
5.5.320.0100.07020.89
5.5.310.0070.08020.73
5.5.300.0070.08720.96
5.5.290.0130.07320.71
5.5.280.0200.07720.99
5.5.270.0070.07721.00
5.5.260.0070.08720.91
5.5.250.0130.07720.73
5.5.240.0100.08020.29
5.5.230.0070.08020.17
5.5.220.0030.08720.17
5.5.210.0170.07020.14
5.5.200.0100.07320.36
5.5.190.0070.07320.18
5.5.180.0070.08020.32
5.5.160.0100.07020.07
5.5.150.0170.05320.23
5.5.140.0070.07020.38
5.5.130.0070.07020.39
5.5.120.0170.06320.40
5.5.110.0200.06720.10
5.5.100.0070.07020.16
5.5.90.0100.07320.29
5.5.80.0170.06320.18
5.5.70.0130.07320.05
5.5.60.0070.07720.04
5.5.50.0170.06720.14
5.5.40.0130.07320.05
5.5.30.0170.06320.20
5.5.20.0230.05320.27
5.5.10.0030.08720.25
5.5.00.0070.07020.19
5.4.450.0170.07319.35
5.4.440.0170.07019.55
5.4.430.0030.08019.35
5.4.420.0030.08719.30
5.4.410.0130.06719.21
5.4.400.0130.06019.02
5.4.390.0030.07319.16
5.4.380.0130.07319.03
5.4.370.0030.08019.04
5.4.360.0070.08019.16
5.4.350.0070.06318.99
5.4.340.0030.07719.01
5.4.320.0070.08019.25
5.4.310.0130.07019.24
5.4.300.0070.07319.02
5.4.290.0100.07319.06
5.4.280.0000.06019.15
5.4.270.0200.06719.00
5.4.260.0130.05019.00
5.4.250.0030.07019.04
5.4.240.0100.07719.00
5.4.230.0100.06718.98
5.4.220.0070.07319.33
5.4.210.0030.05019.31
5.4.200.0100.06718.99
5.4.190.0130.07019.02
5.4.180.0100.07319.13
5.4.170.0200.06319.32
5.4.160.0070.06718.97
5.4.150.0130.06318.96
5.4.140.0100.07016.34
5.4.130.0070.07316.36
5.4.120.0170.06316.67
5.4.110.0130.06016.32
5.4.100.0070.07316.63
5.4.90.0100.06716.52
5.4.80.0070.07316.51
5.4.70.0030.06716.50
5.4.60.0100.07316.50
5.4.50.0100.06716.24
5.4.40.0130.06716.60
5.4.30.0000.08316.56
5.4.20.0000.08016.24
5.4.10.0030.07716.52
5.4.00.0000.07715.98
5.3.290.0100.05314.69
5.3.280.0130.03714.60
5.3.270.0070.07714.68
5.3.260.0070.07714.76
5.3.250.0170.07014.64
5.3.240.0100.06314.64
5.3.230.0130.06014.61
5.3.220.0030.07714.61
5.3.210.0070.08014.45
5.3.200.0070.07314.56
5.3.190.0130.07014.82
5.3.180.0070.04014.66
5.3.170.0070.07014.60
5.3.160.0070.07714.67
5.3.150.0100.07014.68
5.3.140.0030.07714.56
5.3.130.0100.07314.71
5.3.120.0100.05014.61
5.3.110.0100.05314.66
5.3.100.0100.07313.92
5.3.90.0100.06714.05
5.3.80.0070.07014.06
5.3.70.0070.04313.90
5.3.60.0030.07314.05
5.3.50.0100.06014.05
5.3.40.0000.07313.97
5.3.30.0000.07013.93
5.3.20.0100.06713.73
5.3.10.0030.07013.70
5.3.00.0100.05713.68
5.2.170.0130.05712.60
5.2.160.0030.03712.60
5.2.150.0030.06012.60
5.2.140.0030.06312.60
5.2.130.0100.06012.60
5.2.120.0100.06012.60
5.2.110.0070.06312.60
5.2.100.0030.06012.60
5.2.90.0030.06312.60
5.2.80.0070.06312.60
5.2.70.0070.06312.60
5.2.60.0000.04012.60
5.2.50.0030.06312.60
5.2.40.0070.06012.60
5.2.30.0130.05312.60
5.2.20.0000.06012.60
5.2.10.0070.06012.60
5.2.00.0030.06012.60
5.1.60.0100.05012.60
5.1.50.0000.05312.60
5.1.40.0100.05012.60
5.1.30.0000.05712.60
5.1.20.0030.05712.60
5.1.10.0070.05012.60
5.1.00.0030.05012.60
5.0.50.0000.05012.60
5.0.40.0070.04012.60
5.0.30.0000.06712.60
5.0.20.0030.04712.60
5.0.10.0030.02712.60
5.0.00.0000.06312.60
4.4.90.0000.02012.60
4.4.80.0130.02712.60
4.4.70.0000.04012.60
4.4.60.0030.03712.60
4.4.50.0070.03012.60
4.4.40.0030.05312.60
4.4.30.0030.03312.60
4.4.20.0030.03312.60
4.4.10.0000.04012.60
4.4.00.0030.05312.60
4.3.110.0130.02712.60
4.3.100.0100.02312.60
4.3.90.0030.03312.60
4.3.80.0030.05012.60
4.3.70.0000.03712.60
4.3.60.0030.03312.60
4.3.50.0030.03312.60
4.3.40.0070.04712.60
4.3.30.0000.03712.60
4.3.20.0000.03312.60
4.3.10.0000.04012.60
4.3.00.0030.03312.60

preferences:
47.05 ms | 400 KiB | 5 Q