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; 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) { $spl = '{'; $spr = '}'; } else { $spl = '['; $spr = ']'; } return $spl . implode(',', $data) . $spr; } 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[2]): $char = mb_convert_encoding($matches[2], '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; case isset($matches[1]): return '\\n'; default: return '\\r'; } } } $fp = fopen('php://stdin', 'r'); $json = @json_encode(array('a' => 'foo', 'b' => $fp)); var_dump($json);

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.0120.00616.75
8.3.50.0120.00517.43
8.3.40.0110.00418.97
8.3.30.0090.00618.71
8.3.20.0080.00018.77
8.3.10.0040.00420.42
8.3.00.0000.00819.38
8.2.180.0090.00616.88
8.2.170.0180.00322.96
8.2.160.0140.00020.39
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00019.48
8.2.110.0070.00421.07
8.2.100.0080.00317.91
8.2.90.0110.00020.93
8.2.80.0050.00317.93
8.2.70.0000.00817.61
8.2.60.0040.00418.04
8.2.50.0060.00318.07
8.2.40.0060.00318.28
8.2.30.0100.00018.18
8.2.20.0100.00017.77
8.2.10.0000.00817.82
8.2.00.0040.00417.93
8.1.280.0060.01025.92
8.1.270.0050.00324.66
8.1.260.0040.00426.35
8.1.250.0050.00228.09
8.1.240.0090.00022.42
8.1.230.0110.00520.95
8.1.220.0040.00417.78
8.1.210.0000.00818.88
8.1.200.0060.00317.35
8.1.190.0080.00017.40
8.1.180.0000.00818.10
8.1.170.0040.00418.89
8.1.160.0000.00818.98
8.1.150.0070.00018.61
8.1.140.0040.00417.50
8.1.130.0040.00417.79
8.1.120.0000.00717.53
8.1.110.0070.00017.40
8.1.100.0000.00817.43
8.1.90.0020.00517.54
8.1.80.0040.00417.51
8.1.70.0030.00317.52
8.1.60.0030.00517.67
8.1.50.0080.00017.48
8.1.40.0040.00417.58
8.1.30.0000.00717.55
8.1.20.0040.00417.72
8.1.10.0040.00417.59
8.1.00.0000.00817.54
8.0.300.0060.00320.16
8.0.290.0070.00017.00
8.0.280.0060.00318.41
8.0.270.0030.00517.36
8.0.260.0000.00716.90
8.0.250.0000.00716.95
8.0.240.0000.00817.04
8.0.230.0000.00717.11
8.0.220.0030.00317.05
8.0.210.0040.00317.03
8.0.200.0000.00617.09
8.0.190.0000.00817.06
8.0.180.0080.00017.02
8.0.170.0070.00016.93
8.0.160.0040.00417.05
8.0.150.0060.00317.03
8.0.140.0000.00917.01
8.0.130.0000.00613.36
8.0.120.0040.00416.91
8.0.110.0080.00016.88
8.0.100.0040.00416.88
8.0.90.0040.00416.81
8.0.80.0060.01016.98
8.0.70.0040.00417.05
8.0.60.0030.00516.87
8.0.50.0070.00016.89
8.0.30.0160.00617.02
8.0.20.0110.01317.17
8.0.10.0070.00016.93
8.0.00.0150.00916.80
7.4.330.0000.00513.00
7.4.320.0030.00316.55
7.4.300.0040.00416.64
7.4.290.0000.00816.63
7.4.280.0000.01116.57
7.4.270.0000.00716.67
7.4.260.0000.00613.34
7.4.250.0000.00816.52
7.4.240.0000.00716.56
7.4.230.0040.00416.54
7.4.220.0060.01216.61
7.4.210.0090.00716.60
7.4.200.0030.00316.73
7.4.190.0040.00416.54
7.4.160.0050.01116.46
7.4.150.0110.00716.47
7.4.140.0120.00516.56
7.4.130.0070.01016.67
7.4.120.0130.00316.42
7.4.110.0070.01016.69
7.4.100.0040.01416.58
7.4.90.0120.00616.42
7.4.80.0060.01519.39
7.4.70.0030.01316.56
7.4.60.0160.00216.53
7.4.50.0030.00616.48
7.4.40.0000.01616.58
7.4.30.0030.01316.66
7.4.00.0090.00614.76
7.3.330.0000.00613.37
7.3.320.0030.00313.21
7.3.310.0000.00716.41
7.3.300.0000.00716.44
7.3.290.0090.00616.47
7.3.280.0100.00716.41
7.3.270.0130.00716.27
7.3.260.0050.01516.33
7.3.250.0110.00816.62
7.3.240.0050.01416.73
7.3.230.0090.00916.60
7.3.210.0060.01016.54
7.3.200.0100.00716.61
7.3.190.0110.00716.33
7.3.180.0000.01616.46
7.3.170.0000.01516.38
7.3.160.0120.00316.36
7.3.120.0000.01714.82
7.2.330.0190.00616.46
7.2.320.0040.01416.47
7.2.310.0150.00416.67
7.2.300.0100.00716.71
7.2.290.0100.00716.63
7.2.120.0040.00816.32
7.2.110.0040.00716.63
7.2.100.0040.01116.53
7.2.90.0060.00616.41
7.2.80.0070.00716.70
7.2.70.0080.00616.80
7.2.60.0050.00516.85
7.2.50.0030.01016.75
7.2.40.0100.00316.93
7.2.30.0080.00316.91
7.2.20.0090.00316.75
7.2.10.0090.00616.55
7.2.00.0060.00818.21
7.1.240.0090.00615.78
7.1.230.0060.01015.57
7.1.220.0030.01215.77
7.1.210.0050.00515.94
7.1.200.0040.01115.73
7.1.190.0070.00715.92
7.1.180.0070.00715.70
7.1.170.0000.01415.76
7.1.160.0030.00615.78
7.1.150.0070.00715.89
7.1.140.0000.01215.78
7.1.130.0100.00615.46
7.1.120.0140.00015.57
7.1.110.0130.00315.87
7.1.100.0280.00815.47
7.1.90.0070.00715.73
7.1.80.0000.01515.55
7.1.70.0080.00416.33
7.1.60.0100.01017.53
7.1.50.0050.01016.41
7.1.40.0070.00715.86
7.1.30.0000.01115.80
7.1.20.0100.00315.59
7.1.10.0030.00615.84
7.1.00.0060.03619.10
7.0.320.0090.00615.32
7.0.310.0040.00715.43
7.0.300.0040.01115.21
7.0.290.0100.00315.38
7.0.280.0030.01015.31
7.0.270.0060.00615.34
7.0.260.0040.00815.53
7.0.250.0090.00315.34
7.0.240.0030.00515.55
7.0.230.0030.00715.44
7.0.220.0060.00615.31
7.0.210.0060.00615.44
7.0.200.0010.01215.00
7.0.190.0000.00715.15
7.0.180.0090.00615.43
7.0.170.0060.00615.22
7.0.160.0070.00715.03
7.0.150.0110.00015.11
7.0.140.0070.03718.54
7.0.130.0040.00715.26
7.0.120.0040.03318.73
7.0.110.0090.00615.36
7.0.100.0040.01115.08
7.0.90.0310.04417.79
7.0.80.0310.03217.73
7.0.70.0330.04217.72
7.0.60.0250.02417.62
7.0.50.0300.03318.00
7.0.40.0070.04016.70
7.0.30.0130.04216.59
7.0.20.0060.04616.72
7.0.10.0050.04516.72
7.0.00.0080.04316.84
5.6.380.0000.00813.93
5.6.370.0030.00914.26
5.6.360.0030.01314.23
5.6.350.0000.01214.35
5.6.340.0060.00613.90
5.6.330.0070.00414.51
5.6.320.0040.00414.63
5.6.310.0140.00014.27
5.6.300.0030.00914.27
5.6.290.0100.00314.45
5.6.280.0020.04217.81
5.6.270.0070.00714.24
5.6.260.0070.00714.53
5.6.250.0030.01014.04
5.6.240.0070.00313.93
5.6.230.0030.03317.39
5.6.220.0080.03717.46
5.6.210.0070.04317.51
5.6.200.0040.05017.63
5.6.190.0030.03417.84
5.6.180.0100.03317.65
5.6.170.0080.02617.56
5.6.160.0050.04717.65
5.6.150.0050.03217.66
5.6.140.0090.04617.67
5.6.130.0050.04817.52
5.6.120.0060.03017.51
5.6.110.0080.02817.71
5.6.100.0090.04217.54
5.6.90.0050.04517.65
5.6.80.0100.03817.20
5.6.70.0080.04517.26
5.6.60.0110.02617.27
5.6.50.0030.03217.17
5.6.40.0050.04417.23
5.6.30.0030.04817.24
5.6.20.0030.04517.46
5.6.10.0080.02717.19
5.6.00.0070.04017.40
5.5.380.0060.00611.04
5.5.370.0070.04515.84
5.5.360.0060.04415.67
5.5.350.0000.03015.66
5.5.340.0070.02215.98
5.5.330.0080.02515.91
5.5.320.0080.03515.95
5.5.310.0020.04015.94
5.5.300.0080.04216.02
5.5.290.0030.03616.09
5.5.280.0070.04816.08
5.5.270.0060.04816.04
5.5.260.0070.03315.96
5.5.250.0130.04015.92
5.5.240.0100.02315.66
5.5.230.0030.03115.61
5.5.220.0050.04215.53
5.5.210.0070.02515.68
5.5.200.0030.03315.50
5.5.190.0020.03515.71
5.5.180.0040.04815.50
5.5.170.0000.00914.33
5.5.160.0030.03515.67
5.5.150.0040.04415.48
5.5.140.0080.04015.47
5.5.130.0050.04315.66
5.5.120.0030.04515.75
5.5.110.0070.04515.81
5.5.100.0050.03615.65
5.5.90.0050.03415.70
5.5.80.0050.03715.65
5.5.70.0080.04115.62
5.5.60.0140.03215.59
5.5.50.0070.02815.61
5.5.40.0160.02915.40
5.5.30.0130.03515.57
5.5.20.0080.03015.62
5.5.10.0080.03115.63
5.5.00.0100.03815.47
5.4.450.0030.02315.06
5.4.440.0080.04015.26
5.4.430.0050.04315.24
5.4.420.0070.03715.32
5.4.410.0090.03915.36
5.4.400.0110.02715.12
5.4.390.0070.03415.03
5.4.380.0090.03814.97
5.4.370.0050.04014.99
5.4.360.0040.04114.94
5.4.350.0100.03715.08
5.4.340.0080.04015.12
5.4.330.0060.00611.24
5.4.320.0070.03715.13
5.4.310.0010.04114.96
5.4.300.0080.03515.00
5.4.290.0030.04215.01
5.4.280.0060.04314.90
5.4.270.0020.04514.92
5.4.260.0090.03715.13
5.4.250.0050.03515.13
5.4.240.0080.03215.08
5.4.230.0050.03314.94
5.4.220.0090.03815.09
5.4.210.0070.04014.75
5.4.200.0060.03314.93
5.4.190.0080.03815.04
5.4.180.0090.03714.88
5.4.170.0050.03714.89
5.4.160.0030.04314.79
5.4.150.0050.02814.96
5.4.140.0120.03213.66
5.4.130.0110.03313.74
5.4.120.0070.03713.77
5.4.110.0080.03713.67
5.4.100.0080.03513.80
5.4.90.0050.03913.75
5.4.80.0030.04313.72
5.4.70.0030.03213.87
5.4.60.0070.03113.72
5.4.50.0050.02713.71
5.4.40.0050.03813.74
5.4.30.0050.03613.69
5.4.20.0070.02513.81
5.4.10.0100.03213.83
5.4.00.0050.03413.40
5.3.290.0030.04012.56
5.3.280.0100.03612.45
5.3.270.0100.01612.65
5.3.260.0030.04212.56
5.3.250.0000.04512.67
5.3.240.0100.03312.60
5.3.230.0070.03812.60
5.3.220.0090.02512.45
5.3.210.0030.02912.66
5.3.200.0090.01912.55
5.3.190.0050.03712.54
5.3.180.0000.04412.62
5.3.170.0050.04412.69
5.3.160.0030.02512.53
5.3.150.0090.02912.68
5.3.140.0050.03912.57
5.3.130.0050.02612.75
5.3.120.0060.03812.69
5.3.110.0120.03412.50
5.3.100.0030.04012.35
5.3.90.0050.04312.39
5.3.80.0120.03812.24
5.3.70.0070.03812.22
5.3.60.0050.04212.38
5.3.50.0050.04112.29
5.3.40.0070.04012.18
5.3.30.0080.03612.30
5.3.20.0070.03512.02
5.3.10.0060.02312.06
5.3.00.0080.03512.13
5.2.170.0070.03210.55
5.2.160.0000.03310.45
5.2.150.0030.03610.35
5.2.140.0070.03010.42
5.2.130.0020.03510.28
5.2.120.0030.03210.34
5.2.110.0070.03010.31
5.2.100.0060.02310.34
5.2.90.0030.03310.28
5.2.80.0070.03010.28
5.2.70.0020.03110.31
5.2.60.0040.03510.33
5.2.50.0030.03310.37
5.2.40.0050.03110.38
5.2.30.0030.03310.17
5.2.20.0070.03010.23
5.2.10.0020.02710.19
5.2.00.0030.02810.08
5.1.60.0080.0139.71
5.1.50.0030.0319.73
5.1.40.0050.0259.61
5.1.30.0080.0289.82
5.1.20.0050.0199.88
5.1.10.0040.0299.73
5.1.00.0050.0289.75
5.0.50.0020.0288.90
5.0.40.0030.0178.86
5.0.30.0040.0238.86
5.0.20.0040.0198.86
5.0.10.0070.0188.86
5.0.00.0040.0318.86
4.4.90.0000.0218.86
4.4.80.0030.0138.86
4.4.70.0030.0178.86
4.4.60.0020.0208.86
4.4.50.0050.0188.86
4.4.40.0020.0308.86
4.4.30.0060.0178.86
4.4.20.0030.0178.86
4.4.10.0000.0178.86
4.4.00.0060.0178.86
4.3.110.0030.0188.86
4.3.100.0000.0218.86
4.3.90.0070.0128.86
4.3.80.0000.0258.86
4.3.70.0040.0158.86
4.3.60.0050.0188.86
4.3.50.0020.0208.86
4.3.40.0070.0258.86
4.3.30.0020.0208.86
4.3.20.0030.0168.86
4.3.10.0030.0178.86
4.3.00.0020.0208.86

preferences:
49.17 ms | 401 KiB | 5 Q