This article illustrates the method of PHP regular verification of email. Share to everyone for your reference. Specifically as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<?php function Validateemail ($email) {$isValid = true; $atIndex = Strrpo S ($email, "@"); if (Is_bool ($atIndex) &&! $atIndex) {$isValid = false;} else {$domain = substr ($email, $atIndex + 1); $local = su BSTR ($email, 0, $atIndex); $localLen = strlen ($local); $domainLen = strlen ($domain); if ($localLen < 1 | | $localLen >) {//Local part length exceeded $isValid = false;} else if ($domainLen < 1 || $domainLen > 255) {//Domain part length exceeded $isValid = false;} else if ($local [0] = = '. ' | | $local [$localLen-1] == '.') {//Local part starts or ends with '. ' $isValid = false;} else if (Preg_match ('/.. /', $local)) {//Local part has two consecutive dots $isValid = false; else if (!preg_match ('/^[a-za-z0-9-.] +$/', $domain)) {//character not valid into domain part $isValid = false;} else if (Preg_match ('/. /', $domain) {//Domain part has two consecutive dots $isValid = false;} else if (!preg_match ('/^ (. | [a-za-z0-9!#%& ' _=/$ ' *+?^{}|~.-]) +$/', Str_replace ("", "", $local))) {//character not valid in the local part unless//local part is quoted if (!preg_match ('/ ^"("| [^"]) + "$/", Str_replace ("", "", $local))) {$isValid = false;}} if ($isValid &&! ( CHECKDNSRR ($domain, "MX") | | CHECKDNSRR ($domain, "A"))) {//Domain not found in DNS $isValid = false;}} return $isValid; }?> |
I hope this article will help you with your PHP programming.