3v4l.org

run code in 300+ PHP versions simultaneously
<?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) {$nameErr = "Name is required";} else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) {$emailErr = "Email is required";} else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["website"])) {$website = "";} else { $website = test_input($_POST["website"]); // check if URL address syntax is valid (this regular expression also allows dashes in the URL) if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; } } if (empty($_POST["comment"])) {$comment = "";} else {$comment = test_input($_POST["comment"]);} if (empty($_POST["gender"])) {$genderErr = "Gender is required";} else {$gender = test_input($_POST["gender"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>PHP Form Validation Example</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name: <input type="text" name="name" value="<?php echo $name;?>"> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Website: <input type="text" name="website" value="<?php echo $website;?>"> <span class="error"><?php echo $websiteErr;?></span> <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <span class="error">* <?php echo $genderErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> <?php echo "<h2>Your Input:</h2>"; echo $name; echo "<br>"; echo $email; echo "<br>"; echo $website; echo "<br>"; echo $comment; echo "<br>"; echo $gender; ?>

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.0140.00718.25
8.3.50.0100.01021.20
8.3.40.0120.00319.02
8.3.30.0080.00620.30
8.3.20.0000.00820.35
8.3.10.0000.00722.15
8.3.00.0080.00022.51
8.2.180.0160.00316.88
8.2.170.0090.00622.96
8.2.160.0060.00922.11
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0060.00326.16
8.2.120.0080.00020.81
8.2.110.0000.00922.18
8.2.100.0070.00717.72
8.2.90.0000.00817.88
8.2.80.0060.00318.04
8.2.70.0040.00418.05
8.2.60.0030.00618.05
8.2.50.0050.00318.10
8.2.40.0000.00720.59
8.2.30.0000.00919.54
8.2.20.0000.00817.70
8.2.10.0050.00317.78
8.2.00.0030.00617.76
8.1.280.0210.00025.92
8.1.270.0080.00023.99
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0000.00823.97
8.1.230.0000.01119.07
8.1.220.0050.00317.74
8.1.210.0000.00918.77
8.1.200.0000.00917.35
8.1.190.0040.00417.13
8.1.180.0040.00418.10
8.1.170.0040.00418.59
8.1.160.0030.00618.92
8.1.150.0030.00518.73
8.1.140.0040.00417.56
8.1.130.0050.00217.73
8.1.120.0000.00717.54
8.1.110.0030.00617.46
8.1.100.0050.00217.48
8.1.90.0000.00717.45
8.1.80.0020.00517.48
8.1.70.0050.00317.45
8.1.60.0050.00517.53
8.1.50.0040.00417.54
8.1.40.0000.00817.54
8.1.30.0000.00917.65
8.1.20.0060.00317.64
8.1.10.0040.00417.61
8.1.00.0050.00317.55
8.0.300.0040.00419.89
8.0.290.0030.00516.88
8.0.280.0030.00318.51
8.0.270.0000.00717.31
8.0.260.0040.00416.93
8.0.250.0000.00717.01
8.0.240.0020.00517.10
8.0.230.0000.00717.09
8.0.220.0000.00717.04
8.0.210.0030.00317.01
8.0.200.0000.00717.10
8.0.190.0000.00717.02
8.0.180.0000.00716.98
8.0.170.0040.00417.02
8.0.160.0000.00717.00
8.0.150.0040.00417.00
8.0.140.0000.00816.98
8.0.130.0040.00413.42
8.0.120.0000.00816.89
8.0.110.0050.00216.98
8.0.100.0070.00016.85
8.0.90.0080.00016.87
8.0.80.0060.01216.97
8.0.70.0000.00716.98
8.0.60.0060.00316.96
8.0.50.0050.00316.80
8.0.30.0130.00817.22
8.0.20.0110.00817.40
8.0.10.0000.00717.14
8.0.00.0080.01417.02
7.4.330.0000.00715.00
7.4.320.0030.00316.56
7.4.300.0000.00616.63
7.4.290.0000.00816.64
7.4.280.0030.00316.56
7.4.270.0000.00716.60
7.4.260.0030.00313.32
7.4.250.0040.00416.58
7.4.240.0040.00316.56
7.4.230.0000.00716.76
7.4.220.0150.00616.73
7.4.210.0070.00916.67
7.4.200.0000.00716.54
7.4.190.0050.00216.53
7.4.160.0120.00616.66
7.4.150.0030.01417.40
7.4.140.0120.00417.86
7.4.130.0140.00316.68
7.4.120.0070.01016.67
7.4.110.0100.01316.82
7.4.100.0090.00916.64
7.4.90.0100.00716.54
7.4.80.0060.01519.39
7.4.70.0050.01116.46
7.4.60.0150.00416.63
7.4.50.0000.00916.38
7.4.40.0100.00722.77
7.4.30.0180.00416.63
7.4.00.0110.00415.25
7.3.330.0060.00013.42
7.3.320.0020.00213.27
7.3.310.0030.00316.59
7.3.300.0070.00016.47
7.3.290.0070.01416.46
7.3.280.0060.01116.50
7.3.270.0140.00417.40
7.3.260.0100.01716.54
7.3.250.0110.00716.36
7.3.240.0040.01216.44
7.3.230.0090.00916.39
7.3.210.0110.00516.34
7.3.200.0170.00016.54
7.3.190.0130.00716.48
7.3.180.0070.01016.45
7.3.170.0060.01816.66
7.3.160.0140.00416.41
7.3.120.0090.00614.80
7.2.330.0080.01116.79
7.2.320.0170.00016.48
7.2.310.0060.01516.77
7.2.300.0000.01716.69
7.2.290.0110.00616.85
7.2.00.0000.01019.17
7.1.100.0060.00618.04
7.1.70.0030.00517.27
7.1.60.0030.02019.21
7.1.50.0220.01234.82
7.1.00.0000.06722.45
7.0.200.0270.00714.75
7.0.140.0070.06722.15
7.0.80.0270.06719.96
7.0.70.0100.08019.94
7.0.60.0230.08320.01
7.0.50.0670.08020.30
7.0.40.0070.06020.18
7.0.30.0100.08320.14
7.0.20.0070.07020.18
7.0.10.0170.07320.04
7.0.00.0100.08720.08
5.6.280.0000.07720.93
5.6.230.0100.03720.61
5.6.220.0100.04320.68
5.6.210.0030.07020.63
5.6.200.0170.08021.02
5.6.190.0070.07720.98
5.6.180.0100.06321.15
5.6.170.0070.08320.98
5.6.160.0130.06721.12
5.6.150.0100.08021.10
5.6.140.0100.06321.13
5.6.130.0130.07021.18
5.6.120.0170.07721.09
5.6.110.0030.08721.09
5.6.100.0100.05021.02
5.6.90.0070.08721.06
5.6.80.0030.05320.41
5.6.70.0100.07720.34
5.6.60.0030.05020.43
5.6.50.0100.08320.45
5.6.40.0100.08020.48
5.6.30.0130.07320.42
5.6.20.0100.07720.41
5.6.10.0170.06720.41
5.6.00.0100.08020.42
5.5.370.0130.07720.46
5.5.360.0100.04720.38
5.5.350.0200.07720.47
5.5.340.0100.07020.79
5.5.330.0130.08020.78
5.5.320.0030.04320.92
5.5.310.0070.06320.88
5.5.300.0100.08320.85
5.5.290.0070.08720.91
5.5.280.0100.08020.66
5.5.270.0030.08320.93
5.5.260.0070.08020.61
5.5.250.0000.07020.71
5.5.240.0100.07020.30
5.5.230.0100.07320.19
5.5.220.0070.07720.29
5.5.210.0170.07320.15
5.5.200.0030.05020.26
5.5.190.0030.08320.23
5.5.180.0100.06720.16
5.5.160.0100.07719.97
5.5.150.0030.04320.19
5.5.140.0070.08020.25
5.5.130.0100.07720.16
5.5.120.0100.07020.13
5.5.110.0130.07020.12
5.5.100.0170.05720.11
5.5.90.0130.07020.09
5.5.80.0070.07720.08
5.5.70.0070.07020.11
5.5.60.0030.08320.09
5.5.50.0170.04720.03
5.5.40.0130.07719.95
5.5.30.0000.07320.15
5.5.20.0100.07320.09
5.5.10.0130.06320.09
5.5.00.0030.04320.13
5.4.450.0070.08319.56
5.4.440.0170.06319.54
5.4.430.0130.06019.48
5.4.420.0070.07719.47
5.4.410.0070.06319.44
5.4.400.0070.07719.09
5.4.390.0130.07019.18
5.4.380.0070.07719.09
5.4.370.0030.08019.25
5.4.360.0100.07319.09
5.4.350.0100.07719.16
5.4.340.0100.07719.18
5.4.320.0100.07719.03
5.4.310.0030.06018.88
5.4.300.0070.07719.13
5.4.290.0100.07019.10
5.4.280.0030.06018.95
5.4.270.0130.04319.23
5.4.260.0130.05718.84
5.4.250.0070.05718.95
5.4.240.0030.06019.04
5.4.230.0100.07318.94
5.4.220.0130.06018.95
5.4.210.0130.07018.87
5.4.200.0070.07018.84
5.4.190.0030.06319.04
5.4.180.0170.06718.86
5.4.170.0100.03719.11
5.4.160.0100.03319.23
5.4.150.0170.04319.11
5.4.140.0070.06316.46
5.4.130.0070.03716.45
5.4.120.0000.03716.40
5.4.110.0000.04016.29
5.4.100.0000.04716.51
5.4.90.0070.03316.33
5.4.80.0100.02716.49
5.4.70.0000.03716.27
5.4.60.0030.03316.47
5.4.50.0070.02716.54
5.4.40.0030.07716.45
5.4.30.0070.02716.36
5.4.20.0000.03716.40
5.4.10.0100.07016.42
5.4.00.0000.03315.80
5.3.290.0100.07714.65
5.3.280.0030.08314.73
5.3.270.0070.06714.64
5.3.260.0000.05014.61
5.3.250.0070.05314.76
5.3.240.0030.03714.76
5.3.230.0030.04014.57
5.3.220.0030.03714.59
5.3.210.0100.02714.63
5.3.200.0070.03314.48
5.3.190.0070.03014.50
5.3.180.0030.03714.59
5.3.170.0000.04014.65
5.3.160.0000.04014.61
5.3.150.0070.03714.59
5.3.140.0030.04714.71
5.3.130.0000.06714.55
5.3.120.0130.04014.57
5.3.110.0130.05014.57
5.3.100.0070.04714.19
5.3.90.0030.05014.09
5.3.80.0000.04014.09
5.3.70.0070.03314.03
5.3.60.0070.03314.05
5.3.50.0030.03314.03
5.3.40.0030.04013.98
5.3.30.0000.04014.04
5.3.20.0030.03713.73
5.3.10.0030.03313.79
5.3.00.0030.03713.68
5.2.170.0030.03011.60
5.2.160.0030.02711.60
5.2.150.0030.02711.60
5.2.140.0100.02011.60
5.2.130.0000.03711.60
5.2.120.0030.04011.60
5.2.110.0070.05011.60
5.2.100.0030.06711.60
5.2.90.0000.05011.60
5.2.80.0030.02711.60
5.2.70.0000.03011.60
5.2.60.0030.03011.60
5.2.50.0000.03711.60
5.2.40.0000.03011.60
5.2.30.0000.03011.60
5.2.20.0030.02711.60
5.2.10.0030.03011.60
5.2.00.0030.02711.60
5.1.60.0000.03011.60
5.1.50.0000.02711.60
5.1.40.0030.02311.60
5.1.30.0070.04011.60
5.1.20.0070.02011.60
5.1.10.0000.03011.60
5.1.00.0000.02711.62
5.0.50.0000.04011.64
5.0.40.0000.02011.64
5.0.30.0070.02711.64
5.0.20.0070.01311.64
5.0.10.0000.03311.64
5.0.00.0070.05311.64
4.4.90.0030.02011.60
4.4.80.0030.01711.60
4.4.70.0030.02311.60
4.4.60.0000.01311.60
4.4.50.0030.01311.60
4.4.40.0000.02311.60
4.4.30.0030.01711.60
4.4.20.0000.01711.60
4.4.10.0000.02311.62
4.4.00.0000.02711.64
4.3.110.0000.01711.64
4.3.100.0000.01711.64
4.3.90.0030.02311.64
4.3.80.0000.05311.64
4.3.70.0000.03011.64
4.3.60.0000.03711.64
4.3.50.0000.03011.64
4.3.40.0000.04011.64
4.3.30.0070.03011.64
4.3.20.0000.03711.64
4.3.10.0030.03011.64
4.3.00.0030.03311.64

preferences:
56.15 ms | 401 KiB | 5 Q