3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Tell mysqli to throw an exception if an error occurs */ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = new \mysqli("localhost", "my_user", "my_password", "world"); /* The table engine has to support transactions */ $mysqli->query("CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); /* Start transaction */ $mysqli->begin_transaction(); try { /* Insert some values */ $mysqli->query("INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123)"); /* Try to insert invalid values */ $language_code = 'FR'; $native_speakers = 'Unknown'; $stmt = $mysqli->prepare('INSERT INTO language(Code, Speakers) VALUES (?,?)'); $stmt->bind_param('ss', $language_code, $native_speakers); $stmt->execute(); /* If code reaches this point without errors then commit the data in database */ $mysqli->commit(); } catch (\mysqli_sql_exception $exception) { $mysqli->rollback(); throw $exception; } /************************** * Procedural ***************************** / /* Tell mysqli to throw an exception if an error occurs */ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = mysqli_connect("localhost", "my_user", "my_password", "world"); /* The table engine has to support transactions */ mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); /* Start transaction */ mysqli_begin_transaction($mysqli); try { /* Insert some values */ mysqli_query($mysqli, "INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123)"); /* Try to insert invalid values */ $language_code = 'FR'; $native_speakers = 'Unknown'; $stmt = mysqli_prepare($mysqli, 'INSERT INTO language(Code, Speakers) VALUES (?,?)'); mysqli_stmt_bind_param($stmt, 'ss', $language_code, $native_speakers); mysqli_stmt_execute($stmt); /* If code reaches this point without errors then commit the data in database */ mysqli_commit($mysqli); } catch (\mysqli_sql_exception $exception) { mysqli_rollback($mysqli); throw $exception; }

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.40.0170.00021.68
8.3.30.0090.00618.68
8.3.20.0070.00024.18
8.3.10.0040.00424.66
8.3.00.0070.00026.16
8.2.170.0110.00418.79
8.2.160.0070.00722.96
8.2.150.0060.00325.66
8.2.140.0050.00524.66
8.2.130.0090.00026.16
8.2.120.0080.00026.35
8.2.110.0090.00022.30
8.2.100.0090.00317.72
8.2.90.0040.00418.22
8.2.80.0050.00318.98
8.2.70.0090.00317.63
8.2.60.0040.00417.50
8.2.50.0050.00518.05
8.2.40.0040.00418.22
8.2.30.0040.00417.98
8.2.20.0050.00217.91
8.2.10.0030.00519.20
8.2.00.0040.00419.28
8.1.270.0040.00423.99
8.1.260.0050.00328.09
8.1.250.0080.00028.09
8.1.240.0090.00023.80
8.1.230.0040.00820.88
8.1.220.0030.00517.74
8.1.210.0040.00418.77
8.1.200.0060.00317.22
8.1.190.0000.00817.23
8.1.180.0030.00618.10
8.1.170.0030.00618.83
8.1.160.0040.00418.70
8.1.150.0000.00718.82
8.1.140.0070.00018.85
8.1.130.0000.00717.29
8.1.120.0050.00317.25
8.1.110.0000.00817.26
8.1.100.0080.00017.29
8.1.90.0000.00817.38
8.1.80.0000.01117.33
8.1.70.0030.00517.39
8.1.60.0060.00317.50
8.1.50.0040.00417.39
8.1.40.0020.00517.51
8.1.30.0000.00817.59
8.1.20.0060.00317.54
8.1.10.0050.00517.47
8.1.00.0050.00317.42
8.0.300.0000.00820.21
8.0.290.0030.00716.63
8.0.280.0030.00318.32
8.0.270.0000.00718.04
8.0.260.0000.00716.91
8.0.250.0030.00517.03
8.0.240.0040.00416.88
8.0.230.0060.00016.91
8.0.220.0040.00416.81
8.0.210.0040.00316.79
8.0.200.0000.00716.99
8.0.190.0000.00816.89
8.0.180.0000.00716.98
8.0.170.0000.00816.98
8.0.160.0030.00616.88
8.0.150.0040.00416.93
8.0.140.0000.00816.90
8.0.130.0070.00013.27
8.0.120.0000.00916.94
8.0.110.0040.00416.88
8.0.100.0040.00416.81
8.0.90.0070.00016.94
8.0.80.0100.00516.90
8.0.70.0040.00417.03
8.0.60.0040.00416.94
8.0.50.0040.00416.79
8.0.30.0180.00417.01
8.0.20.0100.00817.35
8.0.10.0000.00816.77
8.0.00.0140.00716.63
7.4.330.0020.00216.77
7.4.320.0000.00616.42
7.4.300.0030.00316.46
7.4.290.0030.00316.40
7.4.280.0060.00316.52
7.4.270.0000.00916.58
7.4.260.0050.00013.14
7.4.250.0090.00016.39
7.4.240.0030.00516.55
7.4.230.0070.00016.39
7.4.220.0050.00316.60
7.4.210.0090.00816.54
7.4.200.0040.00416.68
7.4.130.0130.00716.39
7.4.120.0080.00816.47
7.4.110.0150.01516.20
7.4.100.0230.00916.39
7.4.90.0150.00916.21
7.4.80.0230.00416.47
7.4.70.0260.01016.39
7.4.60.0190.01316.47
7.4.50.0290.00316.68
7.4.40.0230.00816.14
7.4.30.0220.00816.48
7.4.20.0140.01316.15
7.4.10.0220.00516.50
7.4.00.0090.01216.64
7.3.330.0050.00516.36
7.3.320.0060.00013.03
7.3.310.0040.00416.13
7.3.300.0030.00316.29
7.3.290.0110.00616.28
7.3.260.0090.01016.55
7.3.240.0290.00316.45
7.3.230.0210.01216.17
7.3.220.0220.00616.26
7.3.210.0220.00816.40
7.3.200.0120.01216.04
7.3.190.0280.00416.51
7.3.180.0240.00716.35
7.3.170.0260.00516.29
7.3.160.0280.00616.46
7.3.150.0220.01116.41
7.3.140.0170.01416.29
7.3.130.0190.01016.27
7.3.120.0210.01016.16
7.3.110.0160.01316.23
7.3.100.0280.01216.48
7.3.90.0240.00916.29
7.3.80.0280.00716.28
7.3.70.0270.00716.27
7.3.60.0330.00716.27
7.3.50.0250.00716.50
7.3.40.0180.00716.31
7.3.30.0170.00916.42
7.3.20.0600.01316.21
7.3.10.0210.01216.27
7.3.00.0160.01016.16
7.2.340.0200.00416.27
7.2.330.0230.01016.52
7.2.320.0300.00016.37
7.2.310.0250.00716.57
7.2.300.0250.00716.48
7.2.290.0170.01416.37
7.2.280.0230.01516.44
7.2.270.0180.01116.50
7.2.260.0240.00616.39
7.2.250.0230.01216.54
7.2.240.0230.01416.60
7.2.230.0260.00716.46
7.2.220.0180.01416.60
7.2.210.0220.01116.73
7.2.200.0250.01416.51
7.2.190.0270.00516.37
7.2.180.0150.01316.42
7.2.170.0130.01316.19
7.2.160.0170.00816.46
7.2.150.0170.00716.33
7.2.140.0260.01216.38
7.2.130.0110.01116.08
7.2.120.0140.01016.27
7.2.110.0250.00416.38
7.2.100.0210.00916.43
7.2.90.0610.00916.35
7.2.80.0140.01016.32
7.2.70.0120.01616.40
7.2.60.0210.00516.58
7.2.50.0160.00816.57
7.2.40.0220.00516.47
7.2.30.0200.01216.47
7.2.20.0260.00416.49
7.2.10.0200.00816.48
7.2.00.0180.01216.52

preferences:
59.26 ms | 400 KiB | 5 Q