3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Validación en PHP</title> <style> .error {color: #FF0000;} </style> </head> <body> <?php // Variables que contendrán un posible mensaje de error $nameErr = $emailErr = $genderErr = $websiteErr = ""; // Variables que guardan el contenido de los campos del formulario $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Nombre necesario"; } else { $name = test_input($_POST["name"]); // verificar si el nombre contiene solo letras y espacios en blanco if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Solo se permiten letras y espacios en blanco"; } } if (empty($_POST["email"])) { $emailErr = "Email necesario"; } else { $email = test_input($_POST["email"]); // verificar si la direccion de correo es valida if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Formato de dirección inválido"; } } if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); // verifica si la URL es válida (la expresion regular también permite guiones en la URL) if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "URL con capacidades diferentes"; } } if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } if (empty($_POST["gender"])) { $genderErr = "Genero necesario"; } else { $gender = test_input($_POST["gender"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>Ejemplo de Validación de Formularios con PHP</h2> <p><span class="error">* campo requerido.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Nombre: <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> Comentario: <textarea name="comment" rows="5" cols="40"></textarea> <br><br> Genero: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="femenino") echo "checked";?> value="femenino">Femenino <input type="radio" name="gender" <?php if (isset($gender) && $gender=="masculino") echo "checked";?> value="masculino">Masculino <span class="error">* <?php echo $genderErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> <?php echo "<h2>Usted Ingresó:</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.40.0120.00318.82
8.3.30.0030.01019.01
8.3.20.0060.00320.34
8.3.10.0080.00023.70
8.3.00.0080.00020.76
8.2.170.0040.01122.96
8.2.160.0030.01020.35
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0070.01126.16
8.2.120.0070.00022.09
8.2.110.0090.00022.07
8.2.100.0120.00018.03
8.2.90.0000.00919.11
8.2.80.0080.00017.97
8.2.70.0050.00617.38
8.2.60.0050.00318.05
8.2.50.0050.00318.07
8.2.40.0080.00018.22
8.2.30.0040.00718.06
8.2.20.0070.00017.88
8.2.10.0000.00717.73
8.2.00.0000.00917.90
8.1.270.0060.00324.02
8.1.260.0050.00326.35
8.1.250.0080.00628.09
8.1.240.0030.00624.01
8.1.230.0070.00419.10
8.1.220.0000.00817.79
8.1.210.0000.00818.77
8.1.200.0000.00917.34
8.1.190.0050.00317.39
8.1.180.0000.00818.10
8.1.170.0040.00718.59
8.1.160.0040.00421.89
8.1.150.0040.00418.55
8.1.140.0040.00417.49
8.1.130.0040.00417.44
8.1.120.0000.00717.40
8.1.110.0000.00717.53
8.1.100.0000.00817.39
8.1.90.0000.00717.54
8.1.80.0040.00517.47
8.1.70.0000.00717.36
8.1.60.0030.00517.51
8.1.50.0030.00517.45
8.1.40.0080.00017.53
8.1.30.0040.00417.63
8.1.20.0040.00417.70
8.1.10.0040.00417.62
8.1.00.0000.00817.51
8.0.300.0070.00018.77
8.0.290.0040.00417.05
8.0.280.0000.00718.39
8.0.270.0000.00717.20
8.0.260.0030.00316.93
8.0.250.0070.00017.12
8.0.240.0000.00717.06
8.0.230.0070.00016.96
8.0.220.0000.00716.96
8.0.210.0040.00316.98
8.0.200.0000.00617.04
8.0.190.0060.00317.14
8.0.180.0070.00016.89
8.0.170.0070.00016.94
8.0.160.0070.00016.98
8.0.150.0050.00216.82
8.0.140.0000.00816.99
8.0.130.0000.00613.35
8.0.120.0040.00416.95
8.0.110.0000.00817.02
8.0.100.0000.00816.88
8.0.90.0000.00716.85
8.0.80.0060.00916.93
8.0.70.0070.00016.94
8.0.60.0050.00217.06
8.0.50.0000.00717.05
8.0.30.0090.01417.16
8.0.20.0090.00917.40
8.0.10.0000.00716.96
8.0.00.0130.01016.81
7.4.330.0000.00515.07
7.4.320.0000.00616.55
7.4.300.0060.00016.68
7.4.290.0070.00016.63
7.4.280.0030.00316.64
7.4.270.0050.00316.48
7.4.260.0000.00816.52
7.4.250.0030.00516.59
7.4.240.0040.00416.63
7.4.230.0000.00716.63
7.4.220.0090.00916.66
7.4.210.0100.00816.61
7.4.200.0030.00316.37
7.4.190.0070.00016.70
7.4.160.0110.00716.60
7.4.150.0100.00717.40
7.4.140.0090.00917.86
7.4.130.0070.01116.52
7.4.120.0130.00916.76
7.4.110.0080.00916.44
7.4.100.0070.01016.47
7.4.90.0090.00916.65
7.4.80.0110.01216.44
7.4.70.0070.01416.49
7.4.60.0030.01516.60
7.4.50.0000.00516.57
7.4.40.0030.01322.77
7.4.30.0100.00816.65
7.4.00.0060.00915.27
7.3.330.0030.00313.27
7.3.320.0000.00613.43
7.3.310.0000.00716.29
7.3.300.0000.00716.33
7.3.290.0040.01816.41
7.3.280.0080.00716.46
7.3.270.0100.00717.40
7.3.260.0060.01316.64
7.3.250.0110.00616.50
7.3.240.0030.01316.59
7.3.230.0110.00716.45
7.3.210.0060.01616.71
7.3.200.0090.00919.39
7.3.190.0140.00816.76
7.3.180.0100.00716.65
7.3.170.0000.01716.43
7.3.160.0080.00816.45
7.3.120.0090.00615.09
7.2.330.0150.00316.73
7.2.320.0140.00616.66
7.2.310.0090.00916.75
7.2.300.0110.00616.77
7.2.290.0090.00616.67
7.2.60.0210.00616.49
7.2.00.0000.01519.23
7.1.200.0080.00415.97
7.1.100.0040.00818.17
7.1.70.0100.00517.10
7.1.60.0100.01319.29
7.1.50.0040.01817.00
7.1.00.0000.08022.30
7.0.200.0160.00616.52
7.0.140.0030.07321.97
7.0.60.0100.08320.01
7.0.50.0130.06717.95
7.0.40.0030.07319.97
7.0.30.0700.05320.06
7.0.20.0230.08020.22
7.0.10.0130.07320.19
7.0.00.0030.06020.25
5.6.280.0100.06721.05
5.6.210.0200.05720.57
5.6.200.0130.07718.28
5.6.190.0100.09020.46
5.6.180.0300.07320.62
5.6.170.0330.03020.51
5.6.160.0000.06320.61
5.6.150.0000.08718.15
5.6.140.0070.08018.28
5.6.130.0000.09018.29
5.6.120.0070.04021.05
5.6.110.0030.05721.06
5.6.100.0000.09021.00
5.6.90.0030.06021.02
5.6.80.0100.06320.40
5.6.70.3930.03720.38
5.5.350.0070.06720.48
5.5.340.0170.06017.96
5.5.330.0070.08320.44
5.5.320.0100.04320.26
5.5.310.0200.04020.27
5.5.300.0000.04317.96
5.5.290.0100.07318.08
5.5.280.0030.05020.90
5.5.270.0100.07020.78
5.5.260.0030.08020.74
5.5.250.0030.04720.68
5.5.240.0200.03720.20
5.4.450.0770.06019.38
5.4.440.0700.06019.18
5.4.430.0900.05019.47
5.4.420.0630.00019.36
5.4.410.0030.06019.01
5.4.400.0070.06018.52
5.4.390.0300.07018.63
5.4.380.0200.05018.76
5.4.370.0200.04318.58
5.4.360.0070.03718.74
5.4.350.0070.03312.04
5.4.340.0110.03212.03
5.4.320.0050.04412.52
5.4.310.0050.03912.52
5.4.300.0060.03612.52
5.4.290.0080.04012.52
5.4.280.0070.03512.41
5.4.270.0040.03912.38
5.4.260.0030.04112.38
5.4.250.0050.03812.38
5.4.240.0070.03512.38
5.4.230.0080.03712.37
5.4.220.0070.03812.37
5.4.210.0050.03712.37
5.4.200.0080.05212.37
5.4.190.0090.03712.37
5.4.180.0050.03812.37
5.4.170.0070.03712.38
5.4.160.0040.03812.38
5.4.150.0040.03812.37
5.4.140.0050.03912.05
5.4.130.0070.03512.04
5.4.120.0040.03812.00
5.4.110.0080.03512.00
5.4.100.0070.03511.99
5.4.90.0060.03912.00
5.4.80.0040.04012.00
5.4.70.0050.03712.00
5.4.60.0050.03712.00
5.4.50.0030.04012.00
5.4.40.0060.03511.98
5.4.30.0100.03311.98
5.4.20.0070.03711.98
5.4.10.0030.03811.98
5.4.00.0060.03811.46
5.3.290.0110.04612.80
5.3.280.0050.04212.71
5.3.270.0050.04112.72
5.3.260.0040.04212.72
5.3.250.0060.03812.72
5.3.240.0080.03712.71
5.3.230.0060.03912.71
5.3.220.0060.03912.68
5.3.210.0100.04212.68
5.3.200.0060.03612.68
5.3.190.0090.03612.68
5.3.180.0040.04212.67
5.3.170.0040.03912.67
5.3.160.0090.03212.68
5.3.150.0050.03812.68
5.3.140.0050.03712.66
5.3.130.0040.04112.66
5.3.120.0080.03812.66
5.3.110.0090.04112.66
5.3.100.0060.03812.12
5.3.90.0090.04012.09
5.3.80.0090.04112.07
5.3.70.0060.04812.07
5.3.60.0110.03712.07
5.3.50.0080.03612.00
5.3.40.0060.04412.00
5.3.30.0080.03411.97
5.3.20.0080.03611.75
5.3.10.0060.03711.71
5.3.00.0050.03911.70
5.2.170.0020.0369.20
5.2.160.0080.0299.20
5.2.150.0080.0299.20
5.2.140.0060.0309.20
5.2.130.0030.0319.16
5.2.120.0050.0309.16
5.2.110.0030.0319.16
5.2.100.0050.0289.18
5.2.90.0020.0319.17
5.2.80.0050.0299.16
5.2.70.0040.0319.16
5.2.60.0060.0309.12
5.2.50.0070.0299.09
5.2.40.0060.0289.06
5.2.30.0050.0309.04
5.2.20.0080.0259.03
5.2.10.0060.0278.95
5.2.00.0060.0298.79
5.1.60.0070.0238.08
5.1.50.0050.0258.08
5.1.40.0040.0278.06
5.1.30.0050.0298.41
5.1.20.0050.0278.43
5.1.10.0050.0278.16
5.1.00.0030.0278.16
5.0.50.0050.0276.63
5.0.40.0080.0236.50
5.0.30.0040.0336.31
5.0.20.0060.0246.29
5.0.10.0080.0266.27
5.0.00.0030.0336.26
4.4.90.0030.0164.78
4.4.80.0070.0124.76
4.4.70.0050.0154.75
4.4.60.0050.0144.75
4.4.50.0010.0174.77
4.4.40.0040.0364.70
4.4.30.0030.0174.76
4.4.20.0040.0154.84
4.4.10.0030.0164.85
4.4.00.0040.0324.76
4.3.110.0030.0204.67
4.3.100.0060.0164.67
4.3.90.0080.0164.63
4.3.80.0060.0244.58
4.3.70.0030.0154.63
4.3.60.0020.0164.63
4.3.50.0060.0134.62
4.3.40.0020.0294.54
4.3.30.0020.0163.32
4.3.20.0040.0143.30
4.3.10.0030.0153.26
4.3.00.0170.0236.79

preferences:
48.38 ms | 400 KiB | 5 Q