Verification of e-mail addresses
Php/*Verify Email address*/function Checkmail ($email) {//user name, by "\w" format character, "-" or "." Composition$email _name="\w| (\w[-.\w]*\w)";//The first paragraph in the domain name, similar to the rule and user name, does not include the dot number "."$code _at="@"; $per _domain="\w| (\w[-\w]*\w)";//the middle part of the domain name, up to two paragraphs$mid _domain="(\.". $per _domain.") {0,2}";//The last paragraph of a domain name can only be ". com", ". org", or ". NET"$end _domain="(\.( com|net|org))"; $rs=Preg_match ("/^{$email _name}@{$per _domain}{$mid _domain}{$end _domain}$/", $email);return(BOOL) $rs;}//test, the following returns the successVar_dump (Checkmail ("root@localhost")); Var_dump (Checkmail ("Frank.Roulan@esun.edu.org")); Var_dump (Checkmail ("Tom.024-1234@x-power_1980.mail-address.com") );?>
The checksum of the URL address
PHP/* Check URL address */function Checkdomain ($domain) {return ereg ( " ^ (http|ftp) s?://(www\.)?. + (com|net|org) $", $domain);} $rs= Checkdomain ("www.taodoor.com"); // return false $rs = Checkdomain ("http://www.taodoor.com"); // back to True ?>
Phone number
PHP/* Verify phone number */function Checktelno ($tel) {// remove extra delimiter $tel = Ereg_replace ("[\ \) \. -]"" ", $tel); // contains only numbers, which should be at least one 6-bit phone number (i.e. no area code) if (Ereg ("^\d+$", $tel)) {returntrue;} Else {returnfalse;}} $rs= Checktelno ("(086) -0411-12345678"); // back to True ?>
Check for ZIP code
PHP/* Check Postal code */function Checkzipcode ($code) {// Remove extra separators $code = Preg_replace ("/[\. -]/"" ", $code); // contains a 6-bit zip code if (Preg_match ("/^\d{6}$/", $code)) {returntrue ;} Else {returnfalse;}} $rs= Checkzipcode ("123456"); // back to True ?>
The above describes the regular expression of the Wed validation application (40), including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.