3v4l.org

run code in 300+ PHP versions simultaneously
<?php $link = mysql_connect('localhost', 'root', 'root'); if (!$link) { die('Could not connect: ' . mysql_error()); } else { echo 'Connected successfully' . "<br>"; } $db_selected = mysql_select_db('Test_DB', $link); if (!$db_selected) { die ('Can\'t use Test_DB : ' . mysql_error()); } else { echo 'Test_DB selected' . "<br>"; } // This SQL statement selects ALL from the table 'Contacts' $sql = "SELECT * FROM Contacts"; $result = mysql_query($sql); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $sql; die($message); } else { echo 'Result: ' . $result; $resultArray = array(); $tempArray = array(); // Loop through each row in the result set while ($row = mysql_fetch_array($result)) { // do stuff - here it works $tempArray = $row; array_push($resultArray, $tempArray); } // Finally, encode the array to JSON and output the results echo json_encode($resultArray); } // Check if there are results // if ($result = mysql_query($link, $sql)) if ($result = mysql_query($sql, $link)) { // If so, then create a results array and a temporary one // to hold the data $resultArray = array(); $tempArray = array(); // Loop through each row in the result set while($row = $result->fetch_object()) { // Add each row into our results array $tempArray = $row; array_push($resultArray, $tempArray); } // Finally, encode the array to JSON and output the results echo json_encode($resultArray); } // Close connections mysql_close($link); ?>

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.70.0140.00418.55
8.3.60.0130.00318.43
8.3.50.0120.00721.05
8.3.40.0070.01118.79
8.3.30.0070.01118.73
8.3.20.0040.00420.36
8.3.10.0030.00523.48
8.3.00.0040.00419.56
8.2.190.0060.00918.56
8.2.180.0110.00718.27
8.2.170.0040.01122.96
8.2.160.0100.00320.52
8.2.150.0100.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00317.63
8.2.110.0030.00620.99
8.2.100.0060.00617.63
8.2.90.0040.00419.22
8.2.80.0040.00417.97
8.2.70.0000.00817.62
8.2.60.0040.00417.90
8.2.50.0050.00318.07
8.2.40.0000.00820.96
8.2.30.0060.00320.64
8.2.20.0000.00917.68
8.2.10.0040.00418.06
8.2.00.0040.00417.91
8.1.280.0060.00925.92
8.1.270.0140.00423.85
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0110.01121.18
8.1.230.0080.00419.16
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0000.01017.23
8.1.190.0000.00817.10
8.1.180.0030.00518.10
8.1.170.0000.01018.51
8.1.160.0040.00421.96
8.1.150.0030.00518.78
8.1.140.0070.00319.15
8.1.130.0070.00017.55
8.1.120.0040.00417.34
8.1.110.0040.00417.22
8.1.100.0040.00417.25
8.1.90.0000.00817.37
8.1.80.0040.00517.38
8.1.70.0070.00017.22
8.1.60.0080.00017.49
8.1.50.0060.00317.48
8.1.40.0040.00417.46
8.1.30.0040.00417.58
8.1.20.0040.00417.46
8.1.10.0040.00417.41
8.1.00.0050.00317.45
8.0.300.0000.00718.77
8.0.290.0050.00316.75
8.0.280.0080.00018.34
8.0.270.0030.00317.17
8.0.260.0000.00717.25
8.0.250.0050.00216.93
8.0.240.0080.00016.99
8.0.230.0030.00316.94
8.0.220.0000.00716.82
8.0.210.0070.00016.91
8.0.200.0000.00717.04
8.0.190.0060.00317.00
8.0.180.0040.00416.81
8.0.170.0000.00816.91
8.0.160.0050.00216.96
8.0.150.0000.00716.83
8.0.140.0040.00416.84
8.0.130.0000.00613.29
8.0.120.0040.00416.82
8.0.110.0000.00816.81
8.0.100.0000.00716.89
8.0.90.0040.00417.02
8.0.80.0090.00616.82
8.0.70.0000.00716.89
8.0.60.0040.00416.96
8.0.50.0040.00416.94
8.0.30.0120.00816.86
8.0.20.0110.00817.40
8.0.10.0040.00417.00
8.0.00.0090.01016.70
7.4.330.0000.00515.08
7.4.320.0030.00316.45
7.4.300.0030.00316.55
7.4.290.0050.00316.35
7.4.280.0060.00316.52
7.4.270.0030.00316.39
7.4.260.0000.00716.43
7.4.250.0080.00016.45
7.4.240.0020.00516.51
7.4.230.0070.00016.29
7.4.220.0040.01416.41
7.4.210.0130.00316.49
7.4.200.0070.00016.35
7.4.160.0080.00816.35
7.4.150.0160.00617.40
7.4.140.0110.01317.86
7.4.130.0120.00616.63
7.4.120.0080.01016.49
7.4.110.0180.00616.50
7.4.100.0090.00916.49
7.4.90.0120.00416.47
7.4.80.0070.01519.39
7.4.70.0070.01016.58
7.4.60.0120.00616.29
7.4.50.0000.00716.52
7.4.40.0070.01016.40
7.4.30.0090.01016.39
7.4.00.0030.01214.85
7.3.330.0000.00513.04
7.3.320.0060.00013.04
7.3.310.0030.00516.32
7.3.300.0050.00216.18
7.3.290.0080.00716.30
7.3.280.0070.01016.30
7.3.270.0030.01317.40
7.3.260.0130.00316.28
7.3.250.0140.00416.41
7.3.240.0100.01916.34
7.3.230.0080.01216.49
7.3.210.0160.00016.52
7.3.200.0140.00716.54
7.3.190.0110.01116.36
7.3.180.0100.00616.42
7.3.170.0180.00416.28
7.3.160.0130.00716.39
7.3.10.0080.00616.41
7.3.00.0110.00316.51
7.2.330.0100.01116.64
7.2.320.0120.01016.59
7.2.310.0000.01816.34
7.2.300.0070.01016.45
7.2.290.0120.00616.30
7.2.130.0030.01016.34
7.2.120.0070.00416.73
7.2.110.0030.01316.86
7.2.100.0110.00416.43
7.2.90.0080.00616.75
7.2.80.0070.01116.60
7.2.70.0110.00316.58
7.2.60.0050.00916.65
7.2.50.0130.00316.66
7.2.40.0060.00916.53
7.2.30.0040.01216.57
7.2.20.0030.01016.60
7.2.10.0040.01116.73
7.2.00.0090.00718.02
7.1.250.0140.00315.64
7.1.240.0090.00915.73
7.1.230.0060.00615.61
7.1.220.0030.01415.63
7.1.210.0120.00615.42
7.1.200.0020.00915.63
7.1.190.0030.00915.54
7.1.180.0070.01115.56
7.1.170.0110.00715.62
7.1.160.0030.01015.34
7.1.150.0060.00615.46
7.1.140.0030.00615.44
7.1.130.0060.00915.49
7.1.120.0060.00915.63
7.1.110.0070.01115.34
7.1.100.0080.00716.81
7.1.90.0070.00715.52
7.1.80.0090.00315.71
7.1.70.0020.00616.41
7.1.60.0100.00617.60
7.1.50.0080.01016.14
7.1.40.0070.00415.34
7.1.30.0030.00715.51
7.1.20.0000.01615.52
7.1.10.0100.00715.38
7.1.00.0080.04018.93
7.0.330.0090.00615.11
7.0.320.0000.01515.04
7.0.310.0030.01215.27
7.0.300.0040.00415.16
7.0.290.0070.00715.07
7.0.280.0060.00915.27
7.0.270.0130.00615.13
7.0.260.0090.00314.92
7.0.250.0030.00615.24
7.0.240.0040.01115.04
7.0.230.0080.00415.15
7.0.220.0130.00314.93
7.0.210.0090.00315.22
7.0.200.0200.00515.67
7.0.190.0090.00315.04
7.0.180.0100.00415.17
7.0.170.0110.00015.42
7.0.160.0070.01015.12
7.0.150.0030.00615.24
7.0.140.0080.00315.23
7.0.130.0050.00515.31
7.0.120.0070.00415.10
7.0.110.0070.00715.40
7.0.100.0030.01315.38
7.0.90.0360.03017.57
7.0.80.0280.02617.56
7.0.70.0370.03717.60
7.0.60.0280.03217.42
7.0.50.0360.04017.82
7.0.40.0070.03116.70
7.0.30.0010.04916.69
7.0.20.0050.03816.51
7.0.10.0040.02616.37
7.0.00.0080.02816.43
5.6.380.0110.00314.06
5.6.370.0090.00313.71
5.6.360.0030.01013.97
5.6.350.0060.00613.46
5.6.340.0070.00714.00
5.6.330.0000.01813.90
5.6.320.0150.00014.09
5.6.310.0070.00713.90
5.6.300.0030.01013.86
5.6.290.0080.00014.05
5.6.280.0010.02117.47
5.6.270.0030.00713.69
5.6.260.0070.01013.42
5.6.250.0030.00714.09
5.6.240.0040.05017.33
5.6.230.0110.03817.22
5.6.220.0020.05017.24
5.6.210.0070.03517.22
5.6.200.0080.04317.40
5.6.190.0020.02917.49
5.6.180.0070.04517.54
5.6.170.0030.04817.56
5.6.160.0080.04317.39
5.6.150.0070.03817.43
5.6.140.0030.03517.52
5.6.130.0070.03917.60
5.6.120.0120.02517.31
5.6.110.0070.02817.46
5.6.100.0070.02517.42
5.6.90.0000.04117.37
5.6.80.0090.01817.02
5.6.70.0140.02017.14
5.6.60.0070.03217.01
5.6.50.0100.02717.24
5.6.40.0050.02617.14
5.6.30.0060.03917.23
5.6.20.0030.04417.16
5.6.10.0050.02917.12
5.6.00.0040.03317.15
5.5.380.0020.02815.51
5.5.370.0050.04215.54
5.5.360.0080.04115.38
5.5.350.0080.03815.53
5.5.340.0120.03715.71
5.5.330.0080.02115.76
5.5.320.0030.02615.67
5.5.310.0070.03015.84
5.5.300.0050.02615.75
5.5.290.0070.04015.93
5.5.280.0050.04015.96
5.5.270.0030.02615.83
5.5.260.0030.04115.76
5.5.250.0070.04015.64
5.5.240.0050.02615.32
5.5.230.0080.02515.36
5.5.220.0050.03815.24
5.5.210.0080.03615.42
5.5.200.0050.04015.43
5.5.190.0020.03915.37
5.5.180.0070.02315.37
5.5.170.0060.00610.38
5.5.160.0090.04015.42
5.5.150.0050.04415.47
5.5.140.0080.04015.32
5.5.130.0070.02815.32
5.5.120.0070.04015.47
5.5.110.0040.02915.36
5.5.100.0070.04015.35
5.5.90.0050.02915.21
5.5.80.0070.04015.39
5.5.70.0060.02715.15
5.5.60.0050.04315.44
5.5.50.0000.04415.32
5.5.40.0070.04215.33
5.5.30.0100.03615.21
5.5.20.0080.02715.14
5.5.10.0000.04315.21
5.5.00.0040.03115.37
5.4.450.0030.03415.04
5.4.440.0030.04015.03
5.4.430.0060.03115.16
5.4.420.0050.03315.21
5.4.410.0080.03914.91
5.4.400.0080.02014.90
5.4.390.0140.03314.87
5.4.380.0050.02314.84
5.4.370.0070.01914.77
5.4.360.0050.03214.81
5.4.350.0020.02414.76
5.4.340.0030.02814.83
5.4.330.0000.01010.82
5.4.320.0060.03514.84
5.4.310.0160.02114.80
5.4.300.0080.03514.83
5.4.290.0040.03014.85
5.4.280.0080.03314.70
5.4.270.0070.02814.84
5.4.260.0050.03514.94
5.4.250.0120.03315.00
5.4.240.0080.03314.80
5.4.230.0050.04214.70
5.4.220.0070.03014.75
5.4.210.0020.03614.59
5.4.200.0070.03814.80
5.4.190.0050.02614.76
5.4.180.0080.03514.69
5.4.170.0030.04314.56
5.4.160.0100.03514.58
5.4.150.0080.03614.81
5.4.140.0050.02213.52
5.4.130.0050.03513.44
5.4.120.0030.02213.61
5.4.110.0080.01813.35
5.4.100.0050.04313.47
5.4.90.0080.03313.52
5.4.80.0060.03313.63
5.4.70.0080.02513.51
5.4.60.0080.03313.54
5.4.50.0000.03013.50
5.4.40.0090.03613.50
5.4.30.0040.02613.57
5.4.20.0080.03113.53
5.4.10.0020.03513.43
5.4.00.0030.04013.12

preferences:
53.03 ms | 401 KiB | 5 Q