php中email邮件地址验证大全集合

在php中地址验证写法各种各样的,下面我来总结几种常用的email地址验证实例,最简单的是直接使用正则表达式preg_match("/^([a-z0-9+_-]+)(.[a-z0-9+_-]+)*@([a-z0-9-]+.)+[a-z]{2,6}$/ix来验证了。

CodeIgniter框架邮件地址验证,代码如下:

  1. /**  
  2.      * Valid Email  
  3.      *  
  4.      * @access  public  
  5.      * @param   string  
  6.      * @return  bool  
  7.      */ 
  8.     function valid_email($str)  
  9.     {  
  10.         return ( ! preg_match("/^([a-z0-9+_-]+)(.[a-z0-9+_-]+)*@([a-z0-9-]+.)+[a-z]{2,6}$/ix"$str)) ? FALSE : TRUE;  
  11.     } 
  12. PHPCMS邮件正则验证 
  13.  代码如下 复制代码 
  14. /**  
  15.  * 判断email格式是否正确  
  16.  * @param $email  
  17.  */ 
  18. function is_email($email) {  
  19.     return strlen($email) > 6 && preg_match("/^[w-.]+@[w-.]+(.w+)+$/"$email);  

WordPress邮件地址验证函数,代码如下:

  1. function is_email( $email$deprecated = false ) {  
  2.     if ( ! emptyempty$deprecated ) )  
  3.         _deprecated_argument( __FUNCTION__'3.0' );  
  4.    
  5.     // Test for the minimum length the email can be  
  6.     if ( strlen$email ) < 3 ) {  
  7.         return apply_filters( 'is_email', false, $email'email_too_short' );  
  8.     }  
  9.    
  10.     // Test for an @ character after the first position  
  11.     if ( strpos$email'@', 1 ) === false ) {  
  12.         return apply_filters( 'is_email', false, $email'email_no_at' );  
  13.     }  
  14.    
  15.     // Split out the local and domain parts  
  16.     list( $local$domain ) = explode'@'$email, 2 );  
  17.    
  18.     // LOCAL PART  
  19.     // Test for invalid characters  
  20.     if ( !preg_match( '/^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+$/', $local ) ) {  
  21.         return apply_filters( 'is_email', false, $email'local_invalid_chars' );  
  22.     }  
  23.    
  24.     // DOMAIN PART  
  25.     // Test for sequences of periods  
  26.     if ( preg_match( '/.{2,}/'$domain ) ) {  
  27.         return apply_filters( 'is_email', false, $email'domain_period_sequence' );  
  28.     }  
  29.    
  30.     // Test for leading and trailing periods and whitespace  
  31.     if ( trim( $domain" tnrx0B." ) !== $domain ) {  
  32.         return apply_filters( 'is_email', false, $email'domain_period_limits' );  
  33.     }  
  34.    
  35.     // Split the domain into subs  
  36.     $subs = explode'.'$domain );  
  37.    
  38.     // Assume the domain will have at least two subs  
  39.     if ( 2 > count$subs ) ) {  
  40.         return apply_filters( 'is_email', false, $email'domain_no_periods' );  
  41.     }  
  42.    
  43.     // Loop through each sub  
  44.     foreach ( $subs as $sub ) {  
  45.         // Test for leading and trailing hyphens and whitespace  
  46.         if ( trim( $sub" tnrx0B-" ) !== $sub ) {  
  47.             return apply_filters( 'is_email', false, $email'sub_hyphen_limits' );  
  48.         }  
  49.    
  50.         // Test for invalid characters  
  51.         if ( !preg_match('/^[a-z0-9-]+$/i'$sub ) ) {  
  52.             return apply_filters( 'is_email', false, $email'sub_invalid_chars' );  
  53.         }  
  54.     }  
  55.    
  56.     // Congratulations your email made it!  
  57.     return apply_filters( 'is_email'$email$email, null );  

下面分享一个自己写的实例,代码如下:

  1. $email = "tanklo_–vehy@yahoo.com.cn"
  2.     function check_email($email) { 
  3.        $pattern_test = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i"
  4.        return  preg_match($pattern_test,$email); 
  5.     } 
  6. echo check_email($email);
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » php中email邮件地址验证大全集合

124 评论

  1. purchase levofloxacin pills levaquin us

  2. order suhagra 100mg generic buy sildalis pill buy estradiol for sale

  3. purchase tiotropium bromide generic minocin pills buy terazosin

  4. help with essays arava pill azulfidine ca

  5. asacol ca buy azelastine order generic irbesartan 150mg

  6. Thank you for content. Area rugs and online home decor store. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  7. indomethacin 50mg us flomax 0.4mg sale buy cenforce 50mg without prescription

  8. order nortriptyline 25 mg generic cost paxil 20mg paxil 10mg ca

  9. After all, what a great site and informative posts, I will upload inbound link – bookmark this web site? Regards, Reader. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  10. famotidine canada prograf pills remeron 15mg cost

  11. Everything is very open and very clear explanation of issues. was truly information. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  12. Good info. Lucky me I reach on your website by accident, I bookmarked it. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  13. Good info. Lucky me I reach on your website by accident, I bookmarked it. Casibom , Casibom Giriş , Casibom Güncel Giriş , Casibom yeni adres . <a href="https://seowebtasarim.net/casibom/&quot; title="Casibin

  14. order ventolin 4mg generic purchase amoxiclav buy augmentin 1000mg online cheap

  15. provigil order online prednisone drug order deltasone 10mg sale

  16. Nice article inspiring thanks. Hello Administ .Click on the Keyword to Enter the Website. Rulet

  17. buy synthroid online levitra uk order levitra pill

  18. losartan 25mg canada cheap cozaar 50mg buy topiramate 100mg for sale

  19. buy ipratropium 100 mcg combivent uk zyvox pills

  20. generic progesterone 100mg cost prometrium buy zyprexa 10mg pill

  21. nebivolol 20mg over the counter nebivolol cheap order clozaril without prescription

  22. order generic tadalafil 40mg cialis coupon buy tadalafil 20mg online cheap

  23. order furosemide 100mg for sale lasix brand buy albuterol 4mg pill

  24. levitra 10mg for sale tizanidine drug hydroxychloroquine 400mg cost

  25. olmesartan where to buy calan 120mg pill purchase divalproex without prescription

  26. finasteride order online viagra ca buy viagra 100mg sale

  27. buy avlosulfon 100 mg for sale aceon sale aceon us

  28. buy terazosin without a prescription actos drug cialis tadalafil 40mg

评论已关闭

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡