正则如下:
$patten='/^[1-9]\d{5}[1-2]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/';//就是最后这个4
如果把最后那个4改成1,就能匹配的上,改成比1大的就不行了
这个正则是想用来匹配身份证号码的,如果哪位大侠有的话希望能发出来借鉴一下~兼容15位和18位的~
回复讨论(解决方案)
表2.常用的限定符
代码/语法 说明
* 重复零次或更多次
+ 重复一次或更多次
? 重复零次或一次
{n} 重复n次
{n,} 重复n次或更多次
{n,m} 重复n到m次
15位的身份证不知道是怎么排列的,给你点参考
1、身份证号码含义:
一代(现已淘汰,不必判断了)
地区代码(6位)出生年(2位)出生月(2位)出生日(2位)顺号(3位) 共15位
二代
地区代码(6位)出生年(4位)出生月(2位)出生日(2位)顺号(3位)校验位(1位) 共18位
校验位可能是 X
2、简单判定,只需判断位数是否正确即可
/^\d{15}(?:\d{2}[\dX])?$/
3、精确判定(二代)应使用校验码生成算法。各种语言的“身份证校验码生成函数”都可以在网上找到
1、身份证号码含义:
一代(现已淘汰,不必判断了)
地区代码(6位)出生年(2位)出生月(2位)出生日(2位)顺号(3位) 共15位
二代
地区代码(6位)出生年(4位)出生月(2位)出生日(2位)顺号(3位)校验位(1位) 共18位
校验位可能是 X
2、简单判定,只需判断位数是否正确即可
/^\d{15}(?:\d{2}[\dX])?$/
3、精确判定……
function validateIdNumber($idnumber){ $patten='/^\d{17}$/'; preg_match($patten,$idnumber,$match); var_dump($match);//为什么这也显示的是FALSE??我16位就可以,加到17就不行了,这到底是什么问题啊??? } validateidnumber(22111111111234563);
validateidnumber( "22111111111234563 " );
用字符串,数值的话就越界了
本来身份证号就应该是字符串
引用 2 楼 xuzuning 的回复:1、身份证号码含义:
一代(现已淘汰,不必判断了)
地区代码(6位)出生年(2位)出生月(2位)出生日(2位)顺号(3位) 共15位
二代
地区代码(6位)出生年(4位)出生月(2位)出生日(2位)顺号(3位)校验位(1位) 共18位
校验位可能是 X
2、简单判定,只需判断位数是否正确即可
/^\d{15}(?:\d……
好吧,我知道问题出在哪了,因为超过16位了以后数字就会变成科学计数方式,所以16位以上的就不是原来的数字了

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)
