在php中地址验证写法各种各样的,下面我来总结几种常用的email地址验证实例,最简单的是直接使用正则表达式preg_match("/^([a-z0-9+_-]+)(.[a-z0-9+_-]+)*@([a-z0-9-]+.)+[a-z]{2,6}$/ix来验证了。
CodeIgniter框架邮件地址验证,代码如下:
- /**
- * Valid Email
- *
- * @access public
- * @param string
- * @return bool
- */
- function valid_email($str)
- {
- return ( ! preg_match("/^([a-z0-9+_-]+)(.[a-z0-9+_-]+)*@([a-z0-9-]+.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
- }
- PHPCMS邮件正则验证
- 代码如下 复制代码
- /**
- * 判断email格式是否正确
- * @param $email
- */
- function is_email($email) {
- return strlen($email) > 6 && preg_match("/^[w-.]+@[w-.]+(.w+)+$/", $email);
- }
WordPress邮件地址验证函数,代码如下:
- function is_email( $email, $deprecated = false ) {
- if ( ! emptyempty( $deprecated ) )
- _deprecated_argument( __FUNCTION__, '3.0' );
- // Test for the minimum length the email can be
- if ( strlen( $email ) < 3 ) {
- return apply_filters( 'is_email', false, $email, 'email_too_short' );
- }
- // Test for an @ character after the first position
- if ( strpos( $email, '@', 1 ) === false ) {
- return apply_filters( 'is_email', false, $email, 'email_no_at' );
- }
- // Split out the local and domain parts
- list( $local, $domain ) = explode( '@', $email, 2 );
- // LOCAL PART
- // Test for invalid characters
- if ( !preg_match( '/^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+$/', $local ) ) {
- return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
- }
- // DOMAIN PART
- // Test for sequences of periods
- if ( preg_match( '/.{2,}/', $domain ) ) {
- return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
- }
- // Test for leading and trailing periods and whitespace
- if ( trim( $domain, " tnrx0B." ) !== $domain ) {
- return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
- }
- // Split the domain into subs
- $subs = explode( '.', $domain );
- // Assume the domain will have at least two subs
- if ( 2 > count( $subs ) ) {
- return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
- }
- // Loop through each sub
- foreach ( $subs as $sub ) {
- // Test for leading and trailing hyphens and whitespace
- if ( trim( $sub, " tnrx0B-" ) !== $sub ) {
- return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
- }
- // Test for invalid characters
- if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) {
- return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
- }
- }
- // Congratulations your email made it!
- return apply_filters( 'is_email', $email, $email, null );
- }
下面分享一个自己写的实例,代码如下:
- $email = "tanklo_–vehy@yahoo.com.cn";
- function check_email($email) {
- $pattern_test = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i";
- return preg_match($pattern_test,$email);
- }
- echo check_email($email);
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » php中email邮件地址验证大全集合
波比源码 » php中email邮件地址验证大全集合
purchase levofloxacin pills levaquin us
order generic avodart 0.5mg order ondansetron 8mg generic generic ondansetron
order suhagra 100mg generic buy sildalis pill buy estradiol for sale
oral tadalafil 20mg order tadalafil generic order amantadine 100mg sale
buy fluvoxamine 50mg pill order ketoconazole for sale glucotrol us
buy cialis 5mg pills buy betnovate online cheap anafranil 25mg
clomid 100mg generic buy albuterol 2mg for sale blackjack online real money
purchase methotrexate for sale methotrexate 10mg sale purchase reglan pill
tamsulosin 0.2mg tablet generic aldactone 25mg spironolactone 25mg over the counter
purchase metronidazole generic buy metronidazole generic buy bactrim online
order deltasone 10mg without prescription order prednisone for sale cheap amoxicillin tablets
brand clarithromycin 250mg buy clonidine 0.1 mg pill order meclizine online cheap
purchase tiotropium bromide generic minocin pills buy terazosin
buy albuterol 100 mcg online cheap cipro 500mg for sale cipro 500mg us
generic singulair viagra 25mg price sildenafil 100mg uk
tadalafil 40mg us play poker online free no sign up free spins no deposit
buy cialis 5mg buy ed medications online tadalafil 10mg cost
online casino for real cash world tavern poker online slot machine
order nifedipine generic order nifedipine 30mg sale buy fexofenadine 180mg without prescription
real money slot machines online pharmacy drugstore buying a research paper for college
help with essays arava pill azulfidine ca
buy doxycycline purchase ventolin inhalator sale buy cleocin 150mg pill
asacol ca buy azelastine order generic irbesartan 150mg
order digoxin 250mg online order generic molnupiravir 200mg cost molnupiravir 200mg
buy amoxil 1000mg online buy amoxil 250mg pill stromectol cost
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…
fosamax order online motrin 400mg over the counter purchase motrin without prescription
indomethacin 50mg us flomax 0.4mg sale buy cenforce 50mg without prescription
order nortriptyline 25 mg generic cost paxil 20mg paxil 10mg ca
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…
famotidine canada prograf pills remeron 15mg cost
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…
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…
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/" title="Casibin
cheap deltasone 5mg order isotretinoin 10mg generic amoxil order
buy isotretinoin pills prednisone 10mg uk purchase ampicillin pill
oral stromectol cost stromectol 3mg for sale order prednisone 20mg sale
buy zofran 8mg sale order zofran pills trimethoprim price
absorica online amoxil 250mg uk azithromycin brand
order ventolin 4mg generic purchase amoxiclav buy augmentin 1000mg online cheap
order prednisolone for sale buy prednisolone 5mg generic generic lasix 40mg