Php mailbox, URL, mobile phone number legality regular _ PHP Tutorial

Source: Internet
Author: User
Tags php email
Php email address, URL, and mobile phone number validity regular. 1. Email judgment: the code is as follows? Phpfunctionis_email ($ email) {returnstrlen ($ email) 6preg_match (^ [w-.] + @ [w-] + (. w +) + $, $ email );}? 2. Url determination: the code is as follows: functionis_url ($ str 1. Email judgment:

The code is as follows:
Function is_email ($ email ){
Return strlen ($ email)> 6 & preg_match ("/^ [w-.] + @ [w-] + (. w +) + $/", $ email );
}
?>

2. determine the Url:

The code is as follows:

Function is_url ($ str ){
Return preg_match ("/^ http: // [A-Za-z0-9] +. [A-Za-z0-9] + [/=? % -&_~ '@ []': +!] * ([^ <> "]) * $/", $ Str );
}

3. determine the mobile phone number:

The code is as follows:
Function is_mobile ($ str ){
Return preg_match ("/^ (d {3}) | (d {3 }-))? 13d {9 }$/", $ str );
}

Http://www.bkjia.com/PHPjc/371790.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/371790.htmlTechArticle1. judge Email: the code is as follows? Php function is_email ($ email) {return strlen ($ email) 6 preg_match (/^ [w-.] + @ [w-] + (. w +) + $/, $ email );}? 2. determine the Url: the code is as follows: function is_url ($ str...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.