jefferis Posted April 24, 2018 Share Posted April 24, 2018 I folks, I have some old forms on client sites that broke with the upgrade to php 7. I am wondering which PCRE to replace this following bit of code, which seems to be the only one in the form that is deprecated: function CheckEmail($email, $optional) { if ( (strlen($email) == 0) && ($optional === kOptional) ) { return true; } elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) { return true; } else { return false; } } Just preg? or one of these? diamond.php PCRE Functions preg_filter — Perform a regular expression search and replace preg_grep — Return array entries that match the pattern preg_last_error — Returns the error code of the last PCRE regex execution preg_match_all — Perform a global regular expression match preg_match — Perform a regular expression match preg_quote — Quote regular expression characters preg_replace_callback_array — Perform a regular expression search and replace using callbacks preg_replace_callback — Perform a regular expression search and replace using a callback preg_replace — Perform a regular expression search and replace preg_split — Split string by a regular expression I'm not doing much coding anymore. However, what happened was when the form was filled out and posted, instead of running the form's code, the actual php file downloaded. TIA, Jeff Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 24, 2018 Share Posted April 24, 2018 (edited) Use the PHP filter_var() function to validate a properly formatted email address http://php.net/manual/en/filter.examples.validation.php Edited April 24, 2018 by Psycho Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.