3v4l.org

run code in 300+ PHP versions simultaneously
<?php //create short variable names $phonee=$_POST['Phone']; $nn="[a-zA-Z]"; $honda=1; $name = check_input($_POST['FirstName']); //run check_input function all all incoming data $fromEmail = check_input($_POST['Email']); $toaddress = "kcambridge@est-static.com"; //INITIAL VALIDATION //Function checks input and strips potential dangerous characters so injection code cannot be //interpereted correctly function check_input($data) { $data = trim($data); // strips any quotes escaped with slashes $data = stripslashes($data); //strips slashes $data = htmlspecialchars($data); //replaces HTML characters like > with HTML version &lt; return $data; } function isEmailValid($fromEmail) { $pattern = "^[_a-z0-9.-]+(\._a-z0-9.-+)*@[a-z0-9.-]+(\.[a-z0-9.-]+)*(\.[a-z]{2,3})$"; if (eregi($pattern,$fromEmail)) { //eregi - case insensitive regular expression match return true; } else { return false; } } //FORM SUBMISSION VALIDATION //Scipt checks for new line characters like "\r" or "\n" which allows spam to create a new line //in email headers. If these characters are found return ERROR if (((!isEmailValid($fromEmail)) || ($fromEmail == "")|| (strlen($_POST["Phone"]) < 10 ) || preg_match("/$nn/",$phonee))) { echo "Error - From email address is Invalid or has been left blank or Phone number is not valid." . "<br/><br/>" . "Please return to form and re-enter a valid Email Address or phone number." . "<br/><br/>"; } else { $to = "kcambridge@est-static.com"; $subject = "Aegis Newsletter Signup"; $from = $_POST['Email']; $message =''. " \n"; foreach($_POST as $name => $data) { if(is_array($data)) { foreach($data as $datum) $message .= $name . ": " . $datum . " \n"; } else $message .= $name . ": " . $data . " \n"; } # Attempt to send email if(mail($to, $subject, $message, "From: $fromEmail")) header('location:thanks.htm'); else echo "Mail send failure - message not sent";} ?>
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key "Phone" in /in/cn9nN on line 3 Warning: Undefined array key "FirstName" in /in/cn9nN on line 6 Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /in/cn9nN on line 13 Warning: Undefined array key "Email" in /in/cn9nN on line 7 Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /in/cn9nN on line 13 Fatal error: Uncaught Error: Call to undefined function eregi() in /in/cn9nN:22 Stack trace: #0 /in/cn9nN(36): isEmailValid('') #1 {main} thrown in /in/cn9nN on line 22
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Warning: Undefined array key "Phone" in /in/cn9nN on line 3 Warning: Undefined array key "FirstName" in /in/cn9nN on line 6 Warning: Undefined array key "Email" in /in/cn9nN on line 7 Fatal error: Uncaught Error: Call to undefined function eregi() in /in/cn9nN:22 Stack trace: #0 /in/cn9nN(36): isEmailValid('') #1 {main} thrown in /in/cn9nN on line 22
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined index: Phone in /in/cn9nN on line 3 Notice: Undefined index: FirstName in /in/cn9nN on line 6 Notice: Undefined index: Email in /in/cn9nN on line 7 Fatal error: Uncaught Error: Call to undefined function eregi() in /in/cn9nN:22 Stack trace: #0 /in/cn9nN(36): isEmailValid('') #1 {main} thrown in /in/cn9nN on line 22
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Call to undefined function eregi() in /in/cn9nN:22 Stack trace: #0 /in/cn9nN(36): isEmailValid('') #1 {main} thrown in /in/cn9nN on line 22
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Undefined index: Phone in /in/cn9nN on line 3 Notice: Undefined index: FirstName in /in/cn9nN on line 6 Notice: Undefined index: Email in /in/cn9nN on line 7 Deprecated: Function eregi() is deprecated in /in/cn9nN on line 22 Error - From email address is Invalid or has been left blank or Phone number is not valid.<br/><br/>Please return to form and re-enter a valid Email Address or phone number.<br/><br/>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Notice: Undefined index: Phone in /in/cn9nN on line 3 Notice: Undefined index: FirstName in /in/cn9nN on line 6 Notice: Undefined index: Email in /in/cn9nN on line 7 Error - From email address is Invalid or has been left blank or Phone number is not valid.<br/><br/>Please return to form and re-enter a valid Email Address or phone number.<br/><br/>

preferences:
335.84 ms | 403 KiB | 459 Q