3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?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 is well-formed if (!filter_var($email, FILTER_VALIDATE_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; ?> </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)
8.3.60.0070.01518.56
8.3.50.0040.01117.99
8.3.40.0090.00618.67
8.3.30.0000.01418.80
8.3.20.0040.00419.32
8.3.10.0080.00021.60
8.3.00.0080.00020.77
8.2.180.0090.00916.63
8.2.170.0140.00722.96
8.2.160.0070.01119.48
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00420.39
8.2.120.0040.00426.35
8.2.110.0070.00421.14
8.2.100.0090.00317.93
8.2.90.0040.00419.21
8.2.80.0080.00017.97
8.2.70.0040.00417.50
8.2.60.0040.00418.05
8.2.50.0000.00818.10
8.2.40.0030.00622.15
8.2.30.0060.00319.34
8.2.20.0000.00717.84
8.2.10.0000.00718.17
8.2.00.0040.00418.23
8.1.280.0100.00725.92
8.1.270.0070.00023.81
8.1.260.0040.00428.09
8.1.250.0000.00728.09
8.1.240.0060.00323.92
8.1.230.0030.01017.85
8.1.220.0000.00817.79
8.1.210.0080.00018.77
8.1.200.0110.00017.35
8.1.190.0000.00817.22
8.1.180.0000.00818.10
8.1.170.0040.00418.59
8.1.160.0070.00018.98
8.1.150.0040.00418.93
8.1.140.0040.00419.50
8.1.130.0030.00317.49
8.1.120.0070.00017.40
8.1.110.0000.00717.48
8.1.100.0000.00817.55
8.1.90.0040.00417.43
8.1.80.0040.00417.43
8.1.70.0030.00317.46
8.1.60.0050.00317.52
8.1.50.0090.00017.52
8.1.40.0050.00317.62
8.1.30.0030.00517.64
8.1.20.0000.00817.67
8.1.10.0030.00617.65
8.1.00.0000.00817.58
8.0.300.0060.00318.77
8.0.290.0060.00316.88
8.0.280.0050.00218.54
8.0.270.0070.00017.31
8.0.260.0030.00316.99
8.0.250.0030.00316.97
8.0.240.0030.00317.00
8.0.230.0000.00716.97
8.0.220.0030.00316.89
8.0.210.0040.00416.86
8.0.200.0030.00317.11
8.0.190.0070.00016.95
8.0.180.0020.00517.00
8.0.170.0080.00017.06
8.0.160.0030.00317.02
8.0.150.0000.00716.93
8.0.140.0040.00416.87
8.0.130.0030.00313.49
8.0.120.0000.00817.01
8.0.110.0050.00216.86
8.0.100.0050.00316.91
8.0.90.0080.00016.83
8.0.80.0090.01216.93
8.0.70.0070.00016.96
8.0.60.0040.00416.98
8.0.50.0000.00716.97
8.0.30.0130.00517.10
8.0.20.0060.01517.40
8.0.10.0040.00417.12
8.0.00.0110.00716.90
7.4.330.0050.00015.13
7.4.320.0060.00016.61
7.4.300.0000.00616.54
7.4.290.0000.00816.55
7.4.280.0080.00016.64
7.4.270.0000.00716.51
7.4.260.0000.00816.53
7.4.250.0040.00416.44
7.4.240.0040.00416.66
7.4.230.0030.00316.75
7.4.220.0080.01216.59
7.4.210.0050.01216.56
7.4.200.0000.00716.64
7.4.160.0130.00316.62
7.4.150.0130.00317.40
7.4.140.0140.00517.86
7.4.130.0110.00616.66
7.4.120.0150.00516.60
7.4.110.0070.01316.49
7.4.100.0070.01016.59
7.4.90.0090.00916.49
7.4.80.0110.01219.39
7.4.70.0150.00616.74
7.4.60.0130.00916.57
7.4.50.0070.01016.68
7.4.40.0170.00316.45
7.4.30.0070.01016.55
7.4.00.0060.01015.18
7.3.330.0040.00413.57
7.3.320.0000.00713.47
7.3.310.0040.00416.44
7.3.300.0030.00316.31
7.3.290.0000.00716.42
7.3.280.0130.00716.43
7.3.270.0160.01017.40
7.3.260.0070.01016.48
7.3.250.0110.00716.59
7.3.240.0070.01016.57
7.3.230.0120.00616.61
7.3.210.0110.00716.61
7.3.200.0060.00916.57
7.3.190.0060.01216.63
7.3.180.0120.00416.58
7.3.170.0060.01216.45
7.3.160.0090.00916.66
7.3.10.0000.01316.50
7.3.00.0030.00616.71
7.2.330.0140.00416.83
7.2.320.0040.02016.66
7.2.310.0070.01916.63
7.2.300.0070.01516.72
7.2.290.0110.01116.38
7.2.130.0070.00716.96
7.2.120.0070.01017.02
7.2.110.0100.00316.65
7.2.100.0000.01316.70
7.2.90.0030.01016.58
7.2.80.0030.01017.01
7.2.70.0040.00817.08
7.2.60.0080.00516.74
7.2.50.0050.00316.80
7.2.40.0110.00017.01
7.2.30.0040.00716.88
7.2.20.0120.00518.22
7.2.10.0000.01116.79
7.2.00.0030.01016.82
7.1.250.0000.01515.87
7.1.200.0030.00915.99
7.1.110.0050.01118.05
7.1.100.1210.00916.87
7.1.90.0880.00616.97
7.1.80.1090.00516.75
7.1.70.1010.00816.00
7.1.60.0970.00733.89
7.1.50.0850.01233.72
7.1.40.0780.01333.16
7.1.30.0850.01133.29
7.1.20.0810.01033.36
7.1.10.0690.01015.42
7.1.00.0720.00915.57
7.0.250.0090.00617.63
7.0.240.1220.00816.58
7.0.230.0990.01016.50
7.0.220.0980.00816.47
7.0.210.0910.00615.61
7.0.200.1200.00715.54
7.0.190.0690.00915.47
7.0.180.1130.00715.14
7.0.170.0710.00815.00
7.0.160.0840.00615.11
7.0.150.0620.01015.01
7.0.140.0670.00715.15
7.0.130.0250.00715.27
7.0.120.0650.00715.20
7.0.110.0580.01015.23
7.0.100.0310.00815.06
7.0.90.0900.01215.18
7.0.80.0610.01115.16
7.0.70.0130.00915.14
7.0.60.0270.01214.90
7.0.50.0320.01115.22
7.0.40.0070.01415.42
7.0.30.0460.00815.31
7.0.20.0490.00815.15
7.0.10.0400.01015.27
7.0.00.0080.01115.31
5.6.300.0060.06320.86
5.6.290.0120.06220.71
5.6.280.0070.06120.84
5.6.270.0160.05220.88
5.6.260.0120.05420.83
5.6.250.0130.05520.89
5.6.240.0100.06420.92
5.6.230.0130.06120.91
5.6.220.0150.05820.78
5.6.210.0160.05120.91
5.6.200.0120.05820.78
5.6.190.0140.05620.81
5.6.180.0130.05720.83
5.6.170.0110.06120.79
5.6.160.0150.06020.87
5.6.150.0140.06520.90
5.6.140.0140.06520.83
5.6.130.0120.05920.80
5.6.120.0140.05920.78
5.6.110.0090.06320.76
5.6.100.0190.06420.73
5.6.90.0110.05620.75
5.6.80.0170.05420.24
5.6.70.0090.06620.20
5.6.60.0100.06820.17
5.6.50.0110.05620.25
5.6.40.0180.04820.27
5.6.30.0120.05920.16
5.6.20.0130.06120.17
5.6.10.0090.05620.16
5.6.00.0120.05220.14
5.5.380.0180.05717.50
5.5.370.0160.05517.55
5.5.360.0160.05817.46
5.5.350.0150.05617.45
5.5.340.0110.06018.00
5.5.330.0160.05318.02
5.5.320.0140.05717.92
5.5.310.0120.05318.02
5.5.300.0150.05218.03
5.5.290.0170.05617.84
5.5.280.0080.06118.00
5.5.270.0130.06217.96
5.5.260.0140.06218.02
5.5.250.0140.06117.55
5.5.240.0150.05717.42
5.5.230.0180.06017.31
5.5.220.0110.06017.33
5.5.210.0170.04617.19
5.5.200.0160.04717.27
5.5.190.0130.05217.20
5.5.180.0120.05617.22
5.5.160.0170.06317.10
5.5.150.0050.06117.43
5.5.140.0110.05517.21
5.5.130.0090.06317.38
5.5.120.0040.06717.24
5.5.110.0100.05417.27
5.5.100.0080.05817.31
5.5.90.0120.04917.17
5.5.80.0090.06017.17
5.5.70.0160.06317.16
5.5.60.0090.05617.29
5.5.50.0080.06417.23
5.5.40.0130.05617.23
5.5.30.0110.06117.24
5.5.20.0090.06717.27
5.5.10.0120.06217.21
5.5.00.0110.05817.27

preferences:
73.68 ms | 401 KiB | 5 Q