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 = ""; $UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $LOWERCASE = "abcdefghijklmnopqrstuvwxyz"; $NUMBERS = "1234567890"; $SYMBOLS = '`~!@#$%^&*()-_=+[{]}\|;:",<.>/?'; $passwordLength = 0; $availableCharacters = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["passwordLength"])) { $passwordLengthErr = "Length is required"; } else { $passwordLength = test_input($_POST["passwordLength"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $passwordLengthErr = "Only letters and white space allowed"; } } if (empty($_POST["gender"])) { $genderErr = "Gender is required"; } else { $gender = test_input($_POST["gender"]); } 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"]);?>"> Password Length: <input type="text" name="name" value="<?php echo $passwordLength;?>"> <span class="error">* <?php echo $passwordLengthErr;?></span> <br><br> Include Letters: <input type="checkbox" name="vehicle" value="<?php echo $includeLetters;?>" checked> 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.0100.00716.88
8.3.50.0100.00622.06
8.3.40.0090.00618.79
8.3.30.0110.00319.04
8.3.20.0040.00420.34
8.3.10.0040.00420.65
8.3.00.0040.00419.26
8.2.180.0070.01016.75
8.2.170.0070.01022.96
8.2.160.0100.00620.53
8.2.150.0060.00324.18
8.2.140.0000.00724.66
8.2.130.0040.00426.16
8.2.120.0070.00021.01
8.2.110.0080.00321.13
8.2.100.0080.00418.28
8.2.90.0040.00419.22
8.2.80.0000.00817.97
8.2.70.0070.00317.63
8.2.60.0060.00318.05
8.2.50.0030.00618.07
8.2.40.0040.00418.34
8.2.30.0080.00019.36
8.2.20.0000.00717.92
8.2.10.0000.00718.11
8.2.00.0000.00817.80
8.1.280.0100.01325.92
8.1.270.0030.00622.20
8.1.260.0040.00426.35
8.1.250.0050.00228.09
8.1.240.0030.00623.74
8.1.230.0000.01217.91
8.1.220.0000.00817.76
8.1.210.0050.00318.77
8.1.200.0000.01117.23
8.1.190.0080.00017.13
8.1.180.0040.00418.10
8.1.170.0030.00518.59
8.1.160.0000.00721.98
8.1.150.0000.00718.95
8.1.140.0040.00417.50
8.1.130.0030.00317.91
8.1.120.0040.00417.41
8.1.110.0040.00417.52
8.1.100.0000.00717.55
8.1.90.0000.00717.47
8.1.80.0080.00417.45
8.1.70.0050.00317.47
8.1.60.0030.00617.61
8.1.50.0060.00317.55
8.1.40.0000.00817.57
8.1.30.0000.00917.64
8.1.20.0000.00817.70
8.1.10.0040.00417.58
8.1.00.0000.00817.54
8.0.300.0030.00518.77
8.0.290.0040.00416.88
8.0.280.0000.00818.50
8.0.270.0050.00317.26
8.0.260.0030.00317.22
8.0.250.0030.00317.10
8.0.240.0070.00017.11
8.0.230.0030.00317.00
8.0.220.0030.00317.04
8.0.210.0000.00817.01
8.0.200.0030.00317.09
8.0.190.0000.00717.00
8.0.180.0000.00817.00
8.0.170.0000.00817.00
8.0.160.0040.00417.04
8.0.150.0000.00716.96
8.0.140.0040.00416.84
8.0.130.0000.00613.42
8.0.120.0050.00317.04
8.0.110.0040.00416.96
8.0.100.0050.00316.90
8.0.90.0040.00416.95
8.0.80.0090.00616.95
8.0.70.0020.00517.04
8.0.60.0070.00016.96
8.0.50.0040.00417.06
8.0.30.0100.00817.05
8.0.20.0130.01217.40
8.0.10.0000.00817.00
8.0.00.0090.00917.07
7.4.330.0020.00215.00
7.4.320.0000.00716.70
7.4.300.0040.00416.56
7.4.290.0050.00316.50
7.4.280.0040.00416.55
7.4.270.0030.00316.63
7.4.260.0070.00016.46
7.4.250.0080.00016.57
7.4.240.0030.00416.63
7.4.230.0000.00716.39
7.4.220.0090.01216.68
7.4.210.0040.01116.76
7.4.200.0000.00716.75
7.4.160.0160.00016.49
7.4.150.0170.00417.40
7.4.140.0120.00817.86
7.4.130.0080.01016.61
7.4.120.0100.00816.64
7.4.110.0130.00316.79
7.4.100.0070.01416.43
7.4.90.0130.00316.61
7.4.80.0030.01619.39
7.4.70.0040.01316.86
7.4.60.0090.00916.64
7.4.50.0040.00416.68
7.4.40.0090.00916.62
7.4.30.0090.00916.53
7.4.00.0110.00715.14
7.3.330.0030.00313.31
7.3.320.0030.00313.48
7.3.310.0030.00316.58
7.3.300.0030.00316.35
7.3.290.0030.01716.48
7.3.280.0050.01016.47
7.3.270.0140.00717.40
7.3.260.0140.00316.45
7.3.250.0070.01316.65
7.3.240.0100.01316.65
7.3.230.0150.00316.62
7.3.210.0160.00716.58
7.3.200.0080.00819.39
7.3.190.0130.01016.60
7.3.180.0110.00616.54
7.3.170.0110.00616.70
7.3.160.0030.01416.67
7.3.120.0110.00615.15
7.3.110.0070.00814.81
7.3.100.0040.01114.87
7.3.90.0060.00814.77
7.3.80.0100.00314.85
7.3.70.0070.00714.79
7.3.60.0070.00514.98
7.3.50.0060.00614.65
7.3.40.0110.00614.96
7.3.30.0050.00914.95
7.3.20.0060.00716.72
7.3.10.0080.00516.60
7.3.00.0090.00316.77
7.2.330.0140.00316.71
7.2.320.0110.00716.67
7.2.310.0150.00316.50
7.2.300.0080.00816.58
7.2.290.0070.00716.47
7.2.250.0050.01415.27
7.2.240.0070.01215.06
7.2.230.0060.00915.21
7.2.220.0030.01314.98
7.2.210.0060.00914.85
7.2.200.0050.00815.11
7.2.190.0090.00515.09
7.2.180.0050.00815.18
7.2.170.0060.00915.13
7.2.00.0000.01419.31
7.1.330.0030.01215.95
7.1.320.0090.00315.81
7.1.310.0020.01015.97
7.1.300.0050.01115.65
7.1.290.0030.01015.66
7.1.280.0080.00615.76
7.1.270.0060.00415.87
7.1.260.0030.00815.83
7.1.100.0040.00818.23
7.1.70.0130.00317.09
7.1.60.0100.01419.61
7.1.50.0180.02134.84
7.1.00.0070.07322.51
7.0.200.0000.00716.77
7.0.140.0030.07322.04
7.0.60.0030.04319.97
7.0.50.0070.08017.89
7.0.40.0100.08020.21
7.0.30.0530.05320.34
7.0.20.0100.05320.07
7.0.10.0070.08720.21
7.0.00.0170.08320.20
5.6.280.0030.07320.95
5.6.210.0100.07020.67
5.6.200.0070.06318.14
5.6.190.0100.08020.62
5.6.180.0400.04320.43
5.6.170.0230.04720.62
5.6.160.0070.04020.43
5.6.150.0070.08018.27
5.6.140.0030.08318.13
5.6.130.0000.07018.14
5.6.120.0070.08020.96
5.6.110.0070.07721.00
5.6.100.0070.05021.16
5.6.90.0070.04020.99
5.6.80.0100.07020.39
5.5.350.0330.06720.34
5.5.340.0000.04717.99
5.5.330.0030.08720.42
5.5.320.0470.03720.36
5.5.310.0230.07020.35
5.5.300.0070.04018.01
5.5.290.0070.08017.93
5.5.280.0070.08020.80
5.5.270.0170.06320.75
5.5.260.0100.08020.89
5.5.250.0130.05020.73
5.5.240.0130.05320.26
5.4.450.0230.04319.39
5.4.440.0230.04319.46
5.4.430.0570.05319.61
5.4.420.0730.05719.54
5.4.410.0770.05319.21
5.4.400.0500.05719.23
5.4.390.0800.04718.89
5.4.380.0370.06018.58
5.4.370.0370.05018.60
5.4.360.0230.05318.48
5.4.350.0200.06318.51
5.4.340.0300.05718.83
5.4.320.0060.03812.52
5.4.310.0030.04212.52
5.4.300.0070.03612.52
5.4.290.0050.03912.52
5.4.280.0070.03512.41
5.4.270.0060.03712.42
5.4.260.0040.03912.41
5.4.250.0080.03612.41
5.4.240.0080.03512.42
5.4.230.0060.03712.41
5.4.220.0070.03512.41
5.4.210.0050.03512.41
5.4.200.0080.03612.41
5.4.190.0080.04612.41
5.4.180.0080.03412.41
5.4.170.0040.03812.42
5.4.160.0090.03212.41
5.4.150.0040.03712.41
5.4.140.0050.03712.09
5.4.130.0080.03412.08
5.4.120.0080.03512.04
5.4.110.0130.03412.03
5.4.100.0070.03812.04
5.4.90.0060.04512.03
5.4.80.0070.04112.03
5.4.70.0090.03612.02
5.4.60.0080.03512.03
5.4.50.0070.03512.03
5.4.40.0070.03412.02
5.4.30.0100.03712.01
5.4.20.0050.03512.02
5.4.10.0060.03412.01
5.4.00.0060.03611.50
5.3.290.0090.03812.80
5.3.280.0080.03712.70
5.3.270.0050.03912.73
5.3.260.0070.04112.72
5.3.250.0060.03812.72
5.3.240.0060.03812.71
5.3.230.0050.03812.71
5.3.220.0070.03612.68
5.3.210.0090.04212.68
5.3.200.0060.04212.68
5.3.190.0030.04212.68
5.3.180.0090.04212.68
5.3.170.0070.03812.67
5.3.160.0130.03912.67
5.3.150.0060.03912.67
5.3.140.0060.04212.66
5.3.130.0090.03912.66
5.3.120.0100.03712.66
5.3.110.0060.04112.66
5.3.100.0070.03612.14
5.3.90.0070.03612.12
5.3.80.0080.03512.11
5.3.70.0110.04112.11
5.3.60.0090.03512.10
5.3.50.0050.03812.05
5.3.40.0050.04112.05
5.3.30.0050.04712.00
5.3.20.0060.04111.79
5.3.10.0090.04511.75
5.3.00.0070.03811.73
5.2.170.0050.0309.25
5.2.160.0040.0309.25
5.2.150.0050.0309.25
5.2.140.0040.0319.25
5.2.130.0040.0299.21
5.2.120.0050.0289.21
5.2.110.0060.0289.21
5.2.100.0110.0229.20
5.2.90.0100.0349.20
5.2.80.0040.0389.20
5.2.70.0070.0289.20
5.2.60.0020.0329.15
5.2.50.0030.0319.12
5.2.40.0050.0289.09
5.2.30.0050.0289.08
5.2.20.0050.0289.06
5.2.10.0060.0268.97
5.2.00.0060.0288.83
5.1.60.0040.0248.11
5.1.50.0030.0258.11
5.1.40.0050.0238.09
5.1.30.0040.0268.44
5.1.20.0030.0278.47
5.1.10.0060.0238.19
5.1.00.0040.0278.19
5.0.50.0030.0216.68
5.0.40.0030.0226.53
5.0.30.0060.0346.35
5.0.20.0060.0246.31
5.0.10.0070.0256.29
5.0.00.0060.0386.29
4.4.90.0040.0154.78
4.4.80.0030.0144.75
4.4.70.0060.0124.75
4.4.60.0040.0154.75
4.4.50.0040.0144.77
4.4.40.0030.0254.70
4.4.30.0060.0184.76
4.4.20.0050.0164.85
4.4.10.0050.0204.85
4.4.00.0020.0294.76
4.3.110.0030.0194.67
4.3.100.0020.0164.66
4.3.90.0030.0144.64
4.3.80.0030.0244.58
4.3.70.0040.0134.63
4.3.60.0010.0164.63
4.3.50.0020.0164.63
4.3.40.0030.0234.54
4.3.30.0030.0223.34
4.3.20.0000.0173.32
4.3.10.0020.0153.27
4.3.00.0030.01013.57

preferences:
46.12 ms | 401 KiB | 5 Q