3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Checks whether a string is valid json. * * @param string $string * @return boolean */ function json_is($string) { try { // try to decode string json_decode($string); } catch (ErrorException $e) { // exception has been caught which means argument wasn't a string and thus is definitely no json. return FALSE; } // check if error occured return (json_last_error() == JSON_ERROR_NONE); } // Make sure the string is not empty and is, in fact, a string. An empty string is not valid JSON. function isJson($string, $assoc = false) { json_decode($string, $assoc); if(!empty($string) && is_string($string)) { json_decode($string, $assoc); return (json_last_error() == JSON_ERROR_NONE); // return json_decode($str) != null; } return false; } $a=['arraiii'=>['dentro'=>234]]; $b=json_encode($a); $c=''; var_dump(isJson($c));

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.00316.50
8.3.50.0170.00522.00
8.3.40.0090.00918.61
8.3.30.0070.01018.93
8.3.20.0070.00020.20
8.3.10.0030.00523.47
8.3.00.0000.00820.89
8.2.180.0090.00918.23
8.2.170.0100.00722.96
8.2.160.0140.00020.53
8.2.150.0080.00824.18
8.2.140.0040.00424.66
8.2.130.0050.00226.16
8.2.120.0040.00420.79
8.2.110.0060.00322.27
8.2.100.0090.00317.91
8.2.90.0000.00819.02
8.2.80.0030.00617.97
8.2.70.0070.00317.50
8.2.60.0040.00417.80
8.2.50.0030.00618.07
8.2.40.0030.00519.79
8.2.30.0070.00318.23
8.2.20.0040.00417.73
8.2.10.0030.00518.03
8.2.00.0070.00317.68
8.1.280.0100.00725.92
8.1.270.0060.00323.92
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00623.96
8.1.230.0080.00419.16
8.1.220.0030.00617.76
8.1.210.0000.00918.77
8.1.200.0070.00317.23
8.1.190.0040.00417.23
8.1.180.0050.00318.10
8.1.170.0080.00018.70
8.1.160.0000.00722.06
8.1.150.0080.00018.64
8.1.140.0040.00417.47
8.1.130.0070.00017.88
8.1.120.0000.00717.36
8.1.110.0000.00717.35
8.1.100.0030.00517.34
8.1.90.0000.00717.35
8.1.80.0050.00217.35
8.1.70.0000.00817.48
8.1.60.0000.00817.51
8.1.50.0020.00517.46
8.1.40.0120.00017.50
8.1.30.0040.00417.57
8.1.20.0060.00317.58
8.1.10.0080.00017.49
8.1.00.0030.00617.41
8.0.300.0000.00718.77
8.0.290.0070.00017.04
8.0.280.0040.00418.45
8.0.270.0070.00017.22
8.0.260.0070.00017.25
8.0.250.0060.00016.92
8.0.240.0000.00716.85
8.0.230.0030.00316.85
8.0.220.0000.00716.91
8.0.210.0080.00016.86
8.0.200.0080.00016.85
8.0.190.0030.00616.97
8.0.180.0040.00416.86
8.0.170.0040.00416.98
8.0.160.0040.00416.85
8.0.150.0000.00716.81
8.0.140.0060.00616.76
8.0.130.0030.00313.28
8.0.120.0050.00316.85
8.0.110.0050.00316.89
8.0.100.0000.00816.80
8.0.90.0000.00816.96
8.0.80.0070.01516.90
8.0.70.0040.00416.79
8.0.60.0040.00416.92
8.0.50.0070.00016.95
8.0.30.0120.00716.99
8.0.20.0110.00917.40
8.0.10.0040.00416.88
8.0.00.0090.00916.69
7.4.330.0060.00015.00
7.4.320.0030.00316.53
7.4.300.0030.00316.43
7.4.290.0030.00316.47
7.4.280.0040.00416.64
7.4.270.0070.00016.56
7.4.260.0030.00516.45
7.4.250.0000.00916.45
7.4.240.0060.00216.63
7.4.230.0030.00316.59
7.4.220.0070.01016.67
7.4.210.0060.00916.59
7.4.200.0040.00416.59
7.4.190.0040.00416.73
7.4.160.0060.01016.50
7.4.150.0120.00617.40
7.4.140.0110.00617.86
7.4.130.0100.00616.60
7.4.120.0050.01116.41
7.4.110.0100.00616.54
7.4.100.0040.01316.53
7.4.90.0120.00616.49
7.4.80.0030.01419.39
7.4.70.0030.01316.49
7.4.60.0130.00316.38
7.4.50.0030.00316.71
7.4.40.0030.01616.65
7.4.30.0040.01116.68
7.4.00.0090.00614.87
7.3.330.0050.00013.11
7.3.320.0030.00313.10
7.3.310.0070.00016.14
7.3.300.0030.00316.29
7.3.290.0060.01216.24
7.3.280.0110.00916.24
7.3.270.0070.01017.40
7.3.260.0150.00916.33
7.3.250.0100.00716.33
7.3.240.0030.01716.46
7.3.230.0070.01016.50
7.3.210.0090.00916.48
7.3.200.0110.00719.39
7.3.190.0140.00316.48
7.3.180.0060.01316.41
7.3.170.0120.00416.27
7.3.160.0070.01016.46
7.3.120.0090.00615.00
7.2.330.0090.00916.55
7.2.320.0110.00616.71
7.2.310.0090.01516.82
7.2.300.0060.01216.71
7.2.290.0110.00816.74
7.2.00.0000.01219.32
7.1.100.0080.00818.09
7.1.70.0000.00817.19
7.1.60.0100.00719.46
7.1.50.0040.01816.70
7.1.00.0000.08022.41
7.0.200.0000.00916.84
7.0.140.0130.06322.21
7.0.90.0600.05719.89
7.0.80.0600.05719.99
7.0.70.0500.05719.92
7.0.60.0370.04320.07
7.0.50.0700.08320.33
7.0.40.0130.07320.13
7.0.30.0100.07320.11
7.0.20.0130.07319.96
7.0.10.0130.07719.95
7.0.00.0130.07319.94
5.6.280.0100.07021.04
5.6.240.0070.09020.51
5.6.230.0100.08020.61
5.6.220.0230.03320.51
5.6.210.0130.07720.77
5.6.200.0030.09321.04
5.6.190.0170.06021.01
5.6.180.0100.08020.94
5.6.170.0030.08021.03
5.6.160.0070.04321.08
5.6.150.0170.04021.10
5.6.140.0170.03721.08
5.6.130.0170.06721.08
5.6.120.0100.07721.08
5.6.110.0000.08721.00
5.6.100.0170.04021.10
5.6.90.0030.08721.09
5.6.80.0100.08020.50
5.6.70.0070.07320.43
5.6.60.0070.05320.39
5.6.50.0030.06720.34
5.6.40.0230.04720.29
5.6.30.0070.06320.47
5.6.20.0100.04720.35
5.6.10.0100.03720.39
5.6.00.0070.07720.38
5.5.380.0030.04720.32
5.5.370.0030.08720.46
5.5.360.0130.06320.39
5.5.350.0100.08020.43
5.5.340.0070.07720.77
5.5.330.0100.04720.93
5.5.320.0170.07320.76
5.5.310.0100.07720.64
5.5.300.0000.05020.91
5.5.290.0070.04720.78
5.5.280.0070.08720.75
5.5.270.0070.04720.77
5.5.260.0030.04720.92
5.5.250.0070.08020.54
5.5.240.0030.06720.32
5.5.230.0100.04320.27
5.5.220.0070.08020.14
5.5.210.0030.06320.21
5.5.200.0070.04720.23
5.5.190.0030.07720.22
5.5.180.0130.04320.27
5.5.160.0070.08320.21
5.5.150.0170.07320.22
5.5.140.0100.07020.08
5.5.130.0230.06020.27
5.5.120.0170.07020.14
5.5.110.0130.07020.07
5.5.100.0130.09020.16
5.5.90.0030.08020.07
5.5.80.0030.05020.00
5.5.70.0070.05719.94
5.5.60.0030.05320.15
5.5.50.0100.07720.08
5.5.40.0070.07320.16
5.5.30.0030.08020.05
5.5.20.0100.05720.14
5.5.10.0100.07320.11
5.5.00.0000.05719.97
5.4.450.0170.07719.24
5.4.440.0070.05319.45
5.4.430.0070.08019.17
5.4.420.0100.04319.53
5.4.410.0170.06019.29
5.4.400.0000.08719.05
5.4.390.0030.04319.23
5.4.380.0070.07319.03
5.4.370.0100.05319.16
5.4.360.0030.04719.20
5.4.350.0130.07318.88
5.4.340.0130.05319.03
5.4.320.0100.07319.25
5.4.310.0130.07018.95
5.4.300.0130.06318.90
5.4.290.0100.07018.92
5.4.280.0130.07319.03
5.4.270.0000.08019.18
5.4.260.0100.07019.12
5.4.250.0070.05719.02
5.4.240.0200.06019.22
5.4.230.0100.07019.22
5.4.220.0000.05019.14
5.4.210.0000.08018.87
5.4.200.0100.04319.11
5.4.190.0070.07719.11
5.4.180.0070.05319.03
5.4.170.0070.07319.02
5.4.160.0000.06018.86
5.4.150.0070.07018.93
5.4.140.0000.08016.43
5.4.130.0070.07316.25
5.4.120.0000.07716.42
5.4.110.0000.04016.38
5.4.100.0030.05316.32
5.4.90.0100.07016.40
5.4.80.0030.03716.38
5.4.70.0100.07016.54
5.4.60.0100.07016.46
5.4.50.0030.06016.36
5.4.40.0070.05316.46
5.4.30.0070.03716.36
5.4.20.0030.08016.47
5.4.10.0130.04016.30
5.4.00.0070.05015.74
5.3.290.0000.06014.73
5.3.280.0100.07014.58
5.3.270.0030.04714.57
5.3.260.0070.07314.62
5.3.250.0070.07714.59
5.3.240.0100.06314.61
5.3.230.0100.07314.69
5.3.220.0100.03714.66
5.3.210.0070.05014.52
5.3.200.0070.07714.58
5.3.190.0070.06714.71
5.3.180.0100.04714.52
5.3.170.0000.06714.51
5.3.160.0000.06014.54
5.3.150.0200.06314.54
5.3.140.0130.07014.54
5.3.130.0070.08014.54
5.3.120.0170.07314.61
5.3.110.0100.06714.69
5.3.100.0170.04314.01
5.3.90.0170.06014.05
5.3.80.0070.07314.13
5.3.70.0070.05314.05
5.3.60.0070.07314.14
5.3.50.0100.06714.07
5.3.40.0030.08314.05
5.3.30.0000.05013.98
5.3.20.0030.04013.77
5.3.10.0100.06713.75
5.3.00.0070.06013.76
5.2.170.0130.04711.28
5.2.160.0030.06711.16
5.2.150.0000.06011.04
5.2.140.0070.04011.20
5.2.130.0030.05011.16
5.2.120.0030.06311.21
5.2.110.0070.05711.16
5.2.100.0100.04711.20
5.2.90.0000.05010.96
5.2.80.0000.04011.16
5.2.70.0030.06311.21
5.2.60.0000.06311.17
5.2.50.0030.03311.07
5.2.40.0100.06011.11
5.2.30.0070.03010.99
5.2.20.0100.04711.03
5.2.10.0030.06310.91
5.2.00.0100.05310.66
5.1.60.0070.03710.07
5.1.50.0000.0279.86
5.1.40.0070.05310.05
5.1.30.0000.04310.26
5.1.20.0070.02310.35
5.1.10.0030.03310.18
5.1.00.0070.0509.96
5.0.50.0000.0408.58
5.0.40.0070.0338.50
5.0.30.0030.0638.33
5.0.20.0000.0438.21
5.0.10.0000.0408.02
5.0.00.0000.0678.21
4.4.90.0000.0237.14
4.4.80.0000.0337.14
4.4.70.0000.0377.14
4.4.60.0030.0377.14
4.4.50.0000.0377.14
4.4.40.0000.0277.14
4.4.30.0000.0377.14
4.4.20.0000.0277.14
4.4.10.0030.0237.14
4.4.00.0000.0507.14
4.3.110.0070.0207.14
4.3.100.0100.0277.14
4.3.90.0030.0337.14
4.3.80.0100.0307.14
4.3.70.0000.0337.14
4.3.60.0030.0237.14
4.3.50.0000.0277.14
4.3.40.0000.0377.14
4.3.30.0030.0377.14
4.3.20.0000.0307.14
4.3.10.0030.0237.14
4.3.00.0030.0177.14

preferences:
43.32 ms | 401 KiB | 5 Q