3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $nameErr = $ageErr = $emailErr = ""; $name = $email = $Introduction = ""; 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["age"])) { $ageErr = "Age is required"; } else { $age = test_input($_POST["age"]); } } 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["Introduction"])) { $Introduction = ""; } else { $Introduction = test_input($_POST["Introduction"]); } } 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> Age: <input type="text" name="Age" value="<?php echo $Age;?>"> <span class="error">* <?php echo $AgeErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Introduction: <textarea name="Introduction" rows="5" cols="40"><?php echo $Introduction;?></textarea> <br><br> <h3>File Upload:</h3> Select a file to upload: <br /> <form action="/php/file_uploader.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" size="50" /> <br /> <input type="submit" value="Upload File" /> <input type="submit" name="submit" value="Submit"> </form> <?php echo "<h2>Your Input:</h2>"; echo $name; echo "<br>"; echo $age; echo "<br>"; echo $email; echo "<br>"; echo $Introduction; echo "<br>"; print strftime('%c'); ?> </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)
5.4.340.0030.05112.02
5.4.320.0080.05212.51
5.4.310.0070.05412.50
5.4.300.0120.03812.51
5.4.290.0070.05512.50
5.4.280.0140.04712.40
5.4.270.0080.05112.40
5.4.260.0080.04612.40
5.4.250.0080.04512.40
5.4.240.0080.04012.40
5.4.230.0080.04012.39
5.4.220.0090.04612.39
5.4.210.0120.04512.39
5.4.200.0100.04912.39
5.4.190.0050.03912.39
5.4.180.0050.05012.39
5.4.170.0090.04412.40
5.4.160.0080.04112.39
5.4.150.0070.05012.39
5.4.140.0050.05312.08
5.4.130.0060.04112.06
5.4.120.0090.03912.03
5.4.110.0070.04412.02
5.4.100.0050.03612.02
5.4.90.0030.04112.02
5.4.80.0060.03812.02
5.4.70.0050.03512.02
5.4.60.0060.03712.02
5.4.50.0060.04212.02
5.4.40.0060.03512.00
5.4.30.0090.04512.00
5.4.20.0060.04612.00
5.4.10.0050.04012.00
5.4.00.0070.04511.49
5.3.290.0040.05012.80
5.3.280.0090.04512.71
5.3.270.0070.05012.72
5.3.260.0110.04812.71
5.3.250.0100.04312.72
5.3.240.0100.04312.72
5.3.230.0070.04412.71
5.3.220.0070.04112.68
5.3.210.0060.04012.68
5.3.200.0050.03712.68
5.3.190.0050.04712.68
5.3.180.0040.04312.67
5.3.170.0070.05412.66
5.3.160.0110.05012.68
5.3.150.0080.04312.67
5.3.140.0110.04812.66
5.3.130.0080.04612.66
5.3.120.0080.03712.66
5.3.110.0080.03712.66
5.3.100.0060.03712.12
5.3.90.0070.03512.09
5.3.80.0030.03912.07
5.3.70.0160.03312.08
5.3.60.0130.03912.06
5.3.50.0070.04412.00
5.3.40.0070.03512.00
5.3.30.0080.04411.96
5.3.20.0080.03511.74
5.3.10.0060.03611.70
5.3.00.0070.03911.70
5.2.170.0040.0379.20
5.2.160.0060.0309.20
5.2.150.0040.0349.20
5.2.140.0050.0339.20
5.2.130.0030.0339.16
5.2.120.0080.0309.16
5.2.110.0100.0249.17
5.2.100.0050.0289.16
5.2.90.0060.0319.16
5.2.80.0060.0429.15
5.2.70.0070.0419.16
5.2.60.0050.0319.11
5.2.50.0070.0319.08
5.2.40.0080.0339.05
5.2.30.0090.0329.03
5.2.20.0020.0329.02
5.2.10.0100.0268.95
5.2.00.0100.0328.80
5.1.60.0070.0308.09
5.1.50.0050.0328.09
5.1.40.0040.0268.07
5.1.30.0060.0268.41
5.1.20.0050.0278.44
5.1.10.0060.0258.16
5.1.00.0040.0268.16
5.0.50.0040.0206.64
5.0.40.0030.0206.50
5.0.30.0030.0326.32
5.0.20.0050.0196.29
5.0.10.0030.0226.26
5.0.00.0060.0346.25
4.4.90.0050.0194.78
4.4.80.0030.0214.75
4.4.70.0050.0184.75
4.4.60.0020.0194.75
4.4.50.0040.0154.77
4.4.40.0020.0264.71
4.4.30.0030.0164.76
4.4.20.0020.0184.84
4.4.10.0020.0194.85
4.4.00.0030.0274.76
4.3.110.0000.0224.66
4.3.100.0030.0224.66
4.3.90.0040.0214.63
4.3.80.0030.0324.59
4.3.70.0040.0204.63
4.3.60.0030.0204.63
4.3.50.0020.0164.63
4.3.40.0050.0284.54
4.3.30.0030.0203.30
4.3.20.0040.0193.28
4.3.10.0020.0213.23
4.3.00.0100.01311.03

preferences:
142.09 ms | 1394 KiB | 7 Q