3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Challenge: make this terrible code safe if((count($_POST) > 0) && (strlen($_POST['password']) == 0 || strlen($_POST['username']) == 0)){ echo "Please enter username and password".PHP_EOL; exit(); } try{ $pdo = new PDO('sqlite::memorytest:'); } catch(PDOException $e){ echo $e->getMessage(); } $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $pdo->exec("DROP TABLE IF EXISTS users"); $pdo->exec("CREATE TABLE users (username VARCHAR(255), password VARCHAR(255))"); $rootPassword = password_hash("secret", PASSWORD_DEFAULT); $pdo->exec("INSERT INTO users (username, password) VALUES ('root', '$rootPassword');"); $statement = $pdo->prepare("SELECT password FROM users WHERE username = ? LIMIT 1"); if($statement->execute(array($_POST['username']))){ $row = $statement->fetchAll(); if(password_verify($_POST['password'], $row[0]['password'])){ echo "Access granted to $username!<br />\n"; exit(); } else{ echo "Access denied for $username!<br>\n"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Challenge 4</title> </head> <body> <form method="post"> <input type="text" name="username" placeholder="username" /> <input type="password" name="password" placeholder="password" /> <input type="submit" value="Submit" /> </form> </body> </html>

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)
7.4.10.0060.01014.89
7.4.00.0090.00915.08
7.3.130.0110.00714.90
7.3.120.0070.01114.70
7.3.110.0130.00314.99
7.3.100.0000.00914.87
7.3.90.0110.00714.83
7.3.80.0060.00314.89
7.3.70.0060.00314.75
7.3.60.0080.00314.73
7.3.50.0000.01514.98
7.3.40.0030.01014.84
7.3.30.0000.01614.93
7.3.20.0030.01316.73
7.3.10.0070.00716.43
7.3.00.0040.00416.85
7.2.260.0030.01215.27
7.2.250.0060.01015.38
7.2.240.0070.01015.41
7.2.230.0130.00015.10
7.2.220.0040.00714.81
7.2.210.0000.01115.36
7.2.200.0060.00615.20
7.2.190.0000.01515.27
7.2.180.0060.00914.86
7.2.170.0070.00715.25
7.2.160.0130.00615.07
7.2.150.0000.00916.92
7.2.140.0030.01017.03
7.2.130.0100.00016.95
7.2.120.0030.00716.85
7.2.110.0030.01017.01
7.2.100.0030.01017.02
7.2.90.0030.00917.19
7.2.80.0030.00616.65
7.2.70.0120.00616.83
7.2.60.0110.00517.06
7.2.50.0030.01017.05
7.2.40.0000.01516.70
7.2.30.0070.00717.13
7.2.20.0030.01016.88
7.2.10.0090.00317.07
7.2.00.0070.01017.09
7.1.330.0130.00315.93
7.1.320.0030.01015.79
7.1.310.0030.01015.74
7.1.300.0070.00715.72
7.1.290.0070.00715.47
7.1.280.0070.00715.55
7.1.270.0040.01115.84
7.1.260.0000.01215.54
7.1.250.0100.00715.86
7.1.240.0000.01015.82
7.1.230.0030.01015.73
7.1.220.0030.00915.66
7.1.210.0030.01015.66
7.1.200.0060.00715.50
7.1.190.0000.01415.81
7.1.180.0060.01215.88
7.1.170.0040.00715.82
7.1.160.0030.01015.79
7.1.150.0070.00715.87
7.1.140.0120.00015.70
7.1.130.0000.01415.69
7.1.120.0030.01415.55
7.1.110.0030.00715.84
7.1.100.0060.00315.40
7.1.90.0040.01215.85
7.1.80.0060.00615.79
7.1.70.0050.00516.65
7.1.60.0090.00917.48
7.1.50.0040.01116.58
7.1.40.0030.00915.43
7.1.30.0120.00315.61
7.1.20.0060.00915.64
7.1.10.0070.00315.75
7.1.00.0030.04219.11
7.0.330.0040.01215.41
7.0.320.0000.00915.20
7.0.310.0070.01015.38
7.0.300.0000.01115.53
7.0.290.0120.00015.41
7.0.280.0030.00615.49
7.0.270.0070.00615.63
7.0.260.0070.01015.40
7.0.250.0100.00715.36
7.0.240.0040.00715.52
7.0.230.0060.00915.36
7.0.220.0110.00415.39
7.0.210.0100.00615.59
7.0.200.0190.00615.33
7.0.190.0030.00915.55
7.0.180.0090.00615.30
7.0.170.0030.01015.14
7.0.160.0110.00015.45
7.0.150.0080.00015.00
7.0.140.0050.04018.72
7.0.130.0130.00315.48
7.0.120.0120.00315.27
7.0.110.0000.01015.35
7.0.100.0090.00315.42
7.0.90.0000.01415.13
7.0.80.0000.01015.31
7.0.70.0050.00515.40
7.0.60.0070.03517.80
7.0.50.0050.02516.63
7.0.40.0030.03016.80
7.0.30.0180.03316.85
7.0.20.0170.04016.82
7.0.10.0020.04716.68
7.0.00.0070.03216.98
5.6.400.0060.00914.59
5.6.390.0060.00914.58
5.6.380.0080.00814.06
5.6.370.0090.00914.65
5.6.360.0000.01614.47
5.6.350.0070.00714.66
5.6.340.0100.00314.57
5.6.330.0070.01113.88
5.6.320.0090.00614.32
5.6.310.0000.00914.66
5.6.300.0000.01114.47
5.6.290.0070.00714.30
5.6.280.0050.04217.63
5.6.270.0030.00914.60
5.6.260.0000.00914.60
5.6.250.0090.00614.41
5.6.240.0000.01214.42
5.6.230.0070.00714.19
5.6.220.0060.00314.41
5.6.210.0150.04017.40
5.6.200.0050.03016.40
5.6.190.0030.04117.30
5.6.180.1840.02517.32
5.6.170.0120.02817.46
5.6.160.0070.02817.36
5.6.150.0120.03816.21
5.6.140.0080.02416.21
5.6.130.0050.02516.28
5.6.120.0050.04517.67
5.6.110.0100.04317.79
5.6.100.0030.03317.71
5.6.90.0080.04217.64
5.6.80.0050.01917.45
5.6.70.2330.02117.32
5.6.60.0030.00714.18
5.6.50.0000.01413.97
5.6.40.0120.00313.96
5.6.30.0120.00314.16
5.6.20.0030.00914.27
5.6.10.0040.00414.16
5.6.00.0100.00314.30
5.5.380.0030.01014.19
5.5.370.0030.00614.20
5.5.360.0000.01014.30
5.5.350.0020.04917.27
5.5.340.0030.02916.21
5.5.330.0050.04717.29
5.5.320.0230.02117.21
5.5.310.0120.03017.25
5.5.300.0020.02715.99
5.5.290.0020.03316.24
5.5.280.0100.04117.58
5.5.270.0050.02517.52
5.5.260.0100.04317.46
5.5.250.0070.03917.38
5.5.240.0020.02117.30
5.5.230.0000.01214.50
5.5.220.0070.00714.42
5.5.210.0030.00713.97
5.5.200.0060.01014.30
5.5.190.0090.00314.30
5.5.180.0060.00914.27
5.5.170.0030.00714.34
5.5.160.0030.00714.31
5.5.150.0030.00614.41
5.5.140.0030.00913.98
5.5.130.0060.00614.18
5.5.120.0030.00614.32
5.5.110.0090.00614.11
5.5.100.0140.00014.21
5.5.90.0040.00714.19
5.5.80.0070.00714.22
5.5.70.0100.00314.19
5.5.60.0070.00314.35
5.5.50.0030.01214.11
5.5.40.0070.00714.16
5.5.30.0100.00014.32
5.5.20.0030.01414.38
5.5.10.0040.01114.44
5.5.00.0040.00914.18
5.4.450.0050.03316.08
5.4.440.0500.02516.09
5.4.430.0370.03716.03
5.4.420.0400.03116.11
5.4.410.0300.02815.99
5.4.400.0030.03115.97
5.4.390.0460.02815.91
5.4.380.0170.03215.65
5.4.370.0080.02315.61
5.4.360.0030.02315.57
5.4.350.0070.01812.31
5.4.340.0040.02412.31
5.4.330.0030.00312.63
5.4.320.0040.02212.55
5.4.310.0020.02512.55
5.4.300.0090.02312.56
5.4.290.0020.02612.55
5.4.280.0070.01812.50
5.4.270.0050.02012.50
5.4.260.0070.02012.50
5.4.250.0080.02615.65
5.4.240.0030.03215.80
5.4.230.0050.03015.74
5.4.220.0030.03315.80
5.4.210.0060.04115.81
5.4.200.0030.04515.74
5.4.190.0080.03515.69
5.4.180.0120.03415.71
5.4.170.0000.03415.81
5.4.160.0070.02715.64
5.4.150.0100.03015.80
5.4.140.0070.02814.59
5.4.130.0050.03914.57
5.4.120.0050.03014.59
5.4.110.0120.03214.50
5.4.100.0090.03014.55
5.4.90.0050.03614.57
5.4.80.0030.03014.49
5.4.70.0070.03314.52
5.4.60.0080.02514.53
5.4.50.0050.03214.51
5.4.40.0080.02514.41
5.4.30.0020.03214.52
5.4.20.0100.02314.45
5.4.10.0100.02714.46
5.4.00.0050.04014.17
5.3.290.0080.02612.71
5.3.280.0050.02813.53
5.3.270.0050.02813.63
5.3.260.0000.03613.63
5.3.250.0070.02513.57
5.3.240.0080.02813.55
5.3.230.0050.03113.55
5.3.220.0050.03213.61
5.3.210.0100.02813.60
5.3.200.0080.03513.65
5.3.190.0090.03713.61
5.3.180.0080.02913.52
5.3.170.0050.04013.61
5.3.160.0100.02513.61
5.3.150.0030.04013.60
5.3.140.0060.04013.59
5.3.130.0030.03113.60
5.3.120.0110.02413.55
5.3.110.0070.03913.60
5.3.100.0090.02313.34
5.3.90.0080.03713.34
5.3.80.0020.02913.24
5.3.70.0070.03513.34
5.3.60.0030.02813.21
5.3.50.0050.02513.34
5.3.40.0060.03613.15
5.3.30.0130.02813.24
5.3.20.0090.02613.18
5.3.10.0120.02813.06
5.3.00.0070.03313.07
5.2.170.0030.04011.05
5.2.160.0100.05311.08
5.2.150.0100.04011.17
5.2.140.0070.05311.32
5.2.130.0000.04711.13
5.2.120.0030.04011.04
5.2.110.0030.04011.10
5.2.100.0000.05011.13
5.2.90.0030.04011.12
5.2.80.0030.05011.13
5.2.70.0100.05011.10
5.2.60.0170.03710.91
5.2.50.0070.04011.05
5.2.40.0030.05311.05
5.2.30.0100.03310.99
5.2.20.0030.05710.74
5.2.10.0100.03310.96
5.2.00.0000.04310.82
5.1.60.0100.04310.03
5.1.50.0000.0509.98
5.1.40.0000.0539.88
5.1.30.0030.03710.12
5.1.20.0070.04310.36
5.1.10.0030.03310.00
5.1.00.0030.03710.05
5.0.50.0030.0278.41
5.0.40.0000.0278.52
5.0.30.0000.0508.29
5.0.20.0000.0408.25
5.0.10.0070.0238.11
5.0.00.0030.0408.41
4.4.90.0030.0277.39
4.4.80.0030.0307.39
4.4.70.0030.0277.39
4.4.60.0000.0237.39
4.4.50.0030.0307.39
4.4.40.0170.0277.39
4.4.30.0130.0137.39
4.4.20.0000.0237.39
4.4.10.0030.0207.39
4.4.00.0000.0337.39
4.3.110.0030.0237.39
4.3.100.0030.0277.39
4.3.90.0030.0207.39
4.3.80.0030.0337.39
4.3.70.0030.0207.39
4.3.60.0000.0237.39
4.3.50.0030.0207.39
4.3.40.0030.0337.39
4.3.30.0000.0237.39
4.3.20.0000.0237.39
4.3.10.0030.0207.39
4.3.00.0130.0237.29

preferences:
28.81 ms | 401 KiB | 5 Q