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")), json_decode('{null:"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.0070.00718.31
8.3.50.0090.01022.05
8.3.40.0140.00718.48
8.3.30.0120.00318.70
8.3.20.0050.00318.60
8.3.10.0000.00819.16
8.3.00.0080.00023.48
8.2.180.0140.00716.88
8.2.170.0090.00922.96
8.2.160.0100.00720.35
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00019.54
8.2.110.0060.00319.30
8.2.100.0060.00618.03
8.2.90.0040.00419.30
8.2.80.0040.00417.97
8.2.70.0060.00317.38
8.2.60.0040.00417.93
8.2.50.0080.00018.10
8.2.40.0090.00020.54
8.2.30.0060.00321.22
8.2.20.0080.00017.71
8.2.10.0040.00417.86
8.2.00.0030.00617.63
8.1.280.0120.00625.92
8.1.270.0040.00423.99
8.1.260.0030.00526.35
8.1.250.0070.00028.09
8.1.240.0060.00323.98
8.1.230.0080.00417.95
8.1.220.0040.00417.78
8.1.210.0000.00918.77
8.1.200.0060.00317.48
8.1.190.0000.00917.36
8.1.180.0040.00418.10
8.1.170.0110.00018.78
8.1.160.0000.00822.19
8.1.150.0030.00618.62
8.1.140.0050.00217.53
8.1.130.0050.00317.89
8.1.120.0030.00617.43
8.1.110.0040.00417.44
8.1.100.0070.00017.47
8.1.90.0040.00417.49
8.1.80.0030.00517.52
8.1.70.0030.00317.42
8.1.60.0030.00617.66
8.1.50.0040.00417.51
8.1.40.0070.00317.60
8.1.30.0030.00517.76
8.1.20.0040.00417.63
8.1.10.0000.00817.49
8.1.00.0040.00417.46
8.0.300.0000.00718.77
8.0.290.0040.00416.88
8.0.280.0070.00018.51
8.0.270.0000.00717.29
8.0.260.0050.00316.88
8.0.250.0050.00217.02
8.0.240.0040.00416.94
8.0.230.0030.00316.99
8.0.220.0030.00316.85
8.0.210.0030.00316.84
8.0.200.0030.00317.05
8.0.190.0070.00017.03
8.0.180.0030.00516.96
8.0.170.0030.00616.86
8.0.160.0000.00716.86
8.0.150.0000.00716.87
8.0.140.0080.00016.94
8.0.130.0030.00313.45
8.0.120.0030.00516.96
8.0.110.0030.00316.94
8.0.100.0000.00816.79
8.0.90.0050.00317.03
8.0.80.0070.00717.00
8.0.70.0000.00816.86
8.0.60.0070.00016.95
8.0.50.0040.00416.84
8.0.30.0090.01617.08
8.0.20.0110.00817.40
8.0.10.0030.00616.90
8.0.00.0080.01116.92
7.4.330.0060.00014.84
7.4.320.0030.00316.60
7.4.300.0000.00616.62
7.4.290.0030.00316.59
7.4.280.0000.00816.54
7.4.270.0000.00816.75
7.4.260.0000.00613.39
7.4.250.0060.00316.54
7.4.240.0030.00416.64
7.4.230.0040.00416.54
7.4.220.0100.01016.40
7.4.210.0080.00716.58
7.4.200.0030.00316.44
7.4.190.0030.00316.49
7.4.160.0110.01416.55
7.4.150.0090.00917.40
7.4.140.0080.01317.86
7.4.130.0080.00816.53
7.4.120.0110.00616.48
7.4.110.0090.00916.48
7.4.100.0160.00716.44
7.4.90.0130.00316.55
7.4.80.0060.01319.39
7.4.70.0090.00616.66
7.4.60.0100.00716.32
7.4.50.0080.00016.30
7.4.40.0060.00622.52
7.4.30.0080.00916.54
7.4.10.0060.01115.67
7.4.00.0090.00715.41
7.3.330.0000.00613.29
7.3.320.0030.00313.37
7.3.310.0070.00016.39
7.3.300.0000.00716.29
7.3.290.0060.01216.36
7.3.280.0080.00916.39
7.3.270.0400.02317.40
7.3.260.0110.00818.24
7.3.250.0110.00716.46
7.3.240.0070.01016.43
7.3.230.0180.00016.39
7.3.210.0070.01016.52
7.3.200.0090.00919.39
7.3.190.0100.00716.66
7.3.180.0090.01216.50
7.3.170.0130.00316.52
7.3.160.0100.00716.72
7.3.130.0100.00715.70
7.3.120.0080.00915.52
7.3.110.0090.00715.65
7.3.100.0050.00915.58
7.3.90.0020.01315.70
7.3.80.0100.00415.86
7.3.70.0050.00715.57
7.3.60.0070.00415.65
7.3.50.0030.01115.42
7.3.40.0110.00515.61
7.3.30.0090.00715.61
7.3.20.0030.01217.42
7.3.10.0080.00817.41
7.3.00.0050.00517.35
7.2.330.0090.00916.63
7.2.320.0100.00716.55
7.2.310.0110.00816.59
7.2.300.0100.00616.78
7.2.290.0070.01016.66
7.2.260.0080.01015.91
7.2.250.0070.01015.70
7.2.240.0050.01115.70
7.2.230.0090.00715.96
7.2.220.0070.01015.72
7.2.210.0090.00515.68
7.2.200.0060.00815.68
7.2.190.0030.01015.80
7.2.180.0110.00615.77
7.2.170.0050.01015.63
7.2.160.0060.00515.81
7.2.150.0070.01017.70
7.2.140.0070.00717.69
7.2.130.0010.01117.56
7.2.120.0050.01117.64
7.2.110.0050.00917.57
7.2.100.0050.01117.54
7.2.90.0130.00317.64
7.2.80.0040.01117.65
7.2.70.0090.00717.66
7.2.60.0050.00717.73
7.2.50.0120.00317.60
7.2.40.0040.01117.48
7.2.30.0100.00617.55
7.2.20.0050.01017.67
7.2.10.0020.00917.40
7.2.00.0120.00618.08
7.1.330.0090.00816.47
7.1.320.0080.00816.50
7.1.310.0030.01216.56
7.1.300.0060.00816.58
7.1.290.0080.00816.39
7.1.280.0060.00816.60
7.1.270.0070.00516.60
7.1.260.0060.00816.52
7.1.250.0070.00916.43
7.1.240.0020.00916.43
7.1.230.0100.00416.56
7.1.220.0030.01016.57
7.1.210.0050.00916.57
7.1.200.0060.00616.51
7.1.190.0060.00616.63
7.1.180.0060.00716.51
7.1.170.0040.01116.52
7.1.160.0060.01016.48
7.1.150.0060.01016.65
7.1.140.0030.01216.58
7.1.130.0070.00816.54
7.1.120.0060.00816.60
7.1.110.0060.00616.56
7.1.100.0080.00717.15
7.1.90.0080.00316.58
7.1.80.0060.01016.51
7.1.70.0050.01016.76
7.1.60.0120.00617.53
7.1.50.0020.01216.73
7.1.40.0050.01016.38
7.1.30.0070.00716.51
7.1.20.0080.00816.64
7.1.10.0090.00616.62
7.1.00.0070.02618.52
7.0.330.0060.00516.16
7.0.320.0030.00816.12
7.0.310.0050.00516.13
7.0.300.0070.00816.21
7.0.290.0050.00516.09
7.0.280.0070.00816.13
7.0.270.0070.00616.18
7.0.260.0080.00816.06
7.0.250.0070.00816.22
7.0.240.0060.00716.19
7.0.230.0090.00716.10
7.0.220.0050.01016.28
7.0.210.0040.00716.34
7.0.200.0040.00716.36
7.0.190.0030.00816.22
7.0.180.0040.00916.36
7.0.170.0030.00816.33
7.0.160.0060.00816.34
7.0.150.0050.00816.21
7.0.140.0010.03318.20
7.0.130.0060.00716.37
7.0.120.0040.00516.11
7.0.110.0070.00616.27
7.0.100.0070.00716.26
7.0.90.0240.02617.52
7.0.80.0200.02917.45
7.0.70.0210.02817.43
7.0.60.0180.01717.52
7.0.50.0250.03417.60
7.0.40.0070.03216.24
7.0.30.0020.03916.16
7.0.20.0090.03016.07
7.0.10.0020.03016.27
7.0.00.0060.02016.21
5.6.400.0110.00315.19
5.6.390.0070.00915.14
5.6.380.0110.00215.11
5.6.370.0090.00415.04
5.6.360.0050.00815.18
5.6.350.0110.00515.24
5.6.340.0070.01015.06
5.6.330.0050.01015.29
5.6.320.0060.01115.17
5.6.310.0050.01115.16
5.6.300.0050.00515.07
5.6.290.0050.00715.24
5.6.280.0030.03017.00
5.6.270.0060.00915.28
5.6.260.0090.00315.10
5.6.250.0050.00515.17
5.6.240.0060.03416.88
5.6.230.0110.02516.84
5.6.220.0020.03416.99
5.6.210.0100.02716.90
5.6.200.0090.03317.08
5.6.190.0080.02917.10
5.6.180.0070.02017.10
5.6.170.0070.03217.09
5.6.160.0100.01716.98
5.6.150.0080.03117.14
5.6.140.0020.02417.27
5.6.130.0050.02517.11
5.6.120.0110.02217.06
5.6.110.0100.02417.11
5.6.100.0050.03617.11
5.6.90.0050.03317.16
5.6.80.0070.03016.77
5.6.70.0080.02016.79
5.6.60.0090.02816.84
5.6.50.0040.02216.98
5.6.40.0030.01916.86
5.6.30.0070.02516.84
5.6.20.0030.02116.94
5.6.10.0080.01816.76
5.6.00.0040.02516.88
5.5.380.0050.02916.93
5.5.370.0050.01716.78
5.5.360.0070.02816.79
5.5.350.0090.02516.94
5.5.340.0070.02817.04
5.5.330.0070.02916.97
5.5.320.0090.02917.01
5.5.310.0050.03316.98
5.5.300.0070.03216.83
5.5.290.0070.02416.85
5.5.280.0040.03017.01
5.5.270.0080.03016.80
5.5.260.0030.02416.97
5.5.250.0030.02316.76
5.5.240.0090.02716.74
5.5.230.0070.02516.80
5.5.220.0040.03316.79
5.5.210.0070.02816.60
5.5.200.0100.01716.67
5.5.190.0040.01916.68
5.5.180.0080.02016.83
5.5.170.0050.00514.70
5.5.160.0040.01716.69
5.5.150.0020.02216.68
5.5.140.0080.03016.73
5.5.130.0040.01916.58
5.5.120.0040.01716.69
5.5.110.0080.02216.83
5.5.100.0070.01516.76
5.5.90.0010.02816.74
5.5.80.0050.02816.66
5.5.70.0070.01616.69
5.5.60.0060.02216.61
5.5.50.0030.03016.77
5.5.40.0090.02316.71
5.5.30.0070.02716.54
5.5.20.0080.02616.76
5.5.10.0100.01816.68
5.5.00.0080.01716.63
5.4.450.0070.02814.26
5.4.440.0020.02114.40
5.4.430.0020.02014.40
5.4.420.0110.02214.35
5.4.410.0040.02114.35
5.4.400.0070.01614.30
5.4.390.0040.01814.27
5.4.380.0050.02714.24
5.4.370.0060.01914.24
5.4.360.0040.01814.35
5.4.350.0020.01914.14
5.4.340.0040.01514.16
5.4.330.0000.01111.72
5.4.320.0030.01914.13
5.4.310.0010.01814.30
5.4.300.0010.01814.29
5.4.290.0040.01614.15
5.4.280.0020.02714.19
5.4.270.0030.01814.23
5.4.260.0050.01614.24
5.4.250.0050.01614.22
5.4.240.0100.01514.30
5.4.230.0030.01614.35
5.4.220.0010.02014.19
5.4.210.0070.01514.29
5.4.200.0050.01714.22
5.4.190.0060.01314.14
5.4.180.0050.01514.13
5.4.170.0040.01714.23
5.4.160.0020.02114.29
5.4.150.0000.02014.24
5.4.140.0060.01313.35
5.4.130.0040.01513.41
5.4.120.0030.01713.48
5.4.110.0040.01613.43
5.4.100.0060.01513.32
5.4.90.0060.01513.44
5.4.80.0040.01713.47
5.4.70.0040.02713.49
5.4.60.0060.02013.22
5.4.50.0020.01713.40
5.4.40.0050.01613.33
5.4.30.0040.01513.36
5.4.20.0040.02013.39
5.4.10.0060.01613.49
5.4.00.0040.01613.07
5.3.290.0020.01812.93
5.3.280.0020.01712.83
5.3.270.0060.02612.94
5.3.260.0020.01712.75
5.3.250.0020.02112.94
5.3.240.0040.01612.77
5.3.230.0040.02112.88
5.3.220.0050.01312.65
5.3.210.0020.01712.57
5.3.200.0030.01812.72
5.3.190.0070.01612.75
5.3.180.0040.01812.89
5.3.170.0030.01912.84
5.3.160.0020.02112.81
5.3.150.0010.02012.75
5.3.140.0030.01812.91
5.3.130.0030.02512.77
5.3.120.0040.01912.80
5.3.110.0050.01612.79
5.3.100.0050.01812.67
5.3.90.0110.01212.61
5.3.80.0070.03012.54
5.3.70.0020.03012.44
5.3.60.0120.01312.61
5.3.50.0070.02712.56
5.3.40.0090.02612.45
5.3.30.0070.02212.53
5.3.20.0050.02112.42
5.3.10.0020.02312.29
5.3.00.0120.02312.23
5.2.170.0000.03711.17
5.2.160.0100.04011.33
5.2.150.0100.06011.24
5.2.140.0030.04011.24
5.2.130.0070.05711.20
5.2.120.0000.06711.19
5.2.110.0100.04711.22
5.2.100.0130.05311.17
5.2.90.0030.06011.20
5.2.80.0030.06311.26
5.2.70.0000.05311.00
5.2.60.0070.04010.98
5.2.50.0030.05010.91
5.2.40.0070.05311.17
5.2.30.0070.05311.10
5.2.20.0030.06310.85
5.2.10.0070.03010.75
5.2.00.0100.06010.84
5.1.60.0070.02010.02
5.1.50.0000.04010.10
5.1.40.0100.0509.86
5.1.30.0100.05310.48
5.1.20.0100.03710.41
5.1.10.0000.06310.19
5.1.00.0070.05310.15
5.0.50.0030.0238.66
5.0.40.0000.0308.34
5.0.30.0070.0308.33
5.0.20.0030.0478.33
5.0.10.0030.0438.33
5.0.00.0000.0678.33
4.4.90.0100.0308.33
4.4.80.0070.0308.33
4.4.70.0100.0308.33
4.4.60.0070.0338.33
4.4.50.0030.0308.33
4.4.40.0030.0308.33
4.4.30.0000.0378.33
4.4.20.0030.0238.33
4.4.10.0000.0208.33
4.4.00.0030.0478.33
4.3.110.0000.0308.33
4.3.100.0000.0378.33
4.3.90.0030.0378.33
4.3.80.0000.0378.33
4.3.70.0030.0178.33
4.3.60.0070.0308.33
4.3.50.0000.0378.33
4.3.40.0070.0478.33
4.3.30.0030.0378.33
4.3.20.0030.0378.33
4.3.10.0000.0378.33
4.3.00.0030.0308.33

preferences:
59.73 ms | 401 KiB | 5 Q