当前位置:网站首页>身份证号正则验证
身份证号正则验证
2022-07-23 09:10:00 【科小洋-lmy】
if (!checkCertNo($input['certNo'])) {
echo "身份证号有误";
}
function checkCertNo($idcard)
{
$len = strlen($idcard);
if ($len != 18) {
return false;
}
$idcard_base = substr($idcard, 0, 17);
//加权因子
$factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
//校验码对应值
$verify_number_list = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
$checksum = 0;
for ($i = 0; $i < strlen($idcard_base); $i++) {
$checksum += substr($idcard_base, $i, 1) * $factor[$i];
}
$mod = $checksum % 11;
return strtoupper(substr($idcard, 17, 1)) == $verify_number_list[$mod];
}
边栏推荐
- Game (2) of 2022 Henan Mengxin League: solution to supplementary questions of Henan University of Technology
- js纹理样式饼图插件
- CPU, memory, disk speed comparison
- Optimize Huawei ECs to use key login
- uni-app知识点和项目上遇到的问题和解决办法的记录
- 【软件测试】如何梳理你测试的业务
- Tell you Web3.0 I understand
- (重链剖分)魔法树
- Ffmpeg 2 - use of ffplay, ffprobe, ffmpeg commands
- webstrom ERROR in [eslint] ESLint is not a constructor
猜你喜欢

Qt文档阅读笔记-Audio Example解析

After using vscode to format the code, save and find that the code is messy again. What should I do? Vs remove formatting

Vk36n5d anti power interference / mobile phone interference 5-key 5-channel touch detection chip anti freeze function ponding in the touch area can still be operated

LZ77文件压缩

ValidationError: Invalid options object. Dev Server has been initialized using an options object th
![[WinForm] desktop program implementation scheme for screenshot recognition and calculation](/img/9f/e67af4386cff9febf0fb5203da03f0.jpg)
[WinForm] desktop program implementation scheme for screenshot recognition and calculation

利用js自动解析执行xss

koa框架的使用

VK36N5D抗电源干扰/手机干扰 5键5通道触摸检测芯片防呆功能触摸区域积水仍可操作
![[C language] number guessing game + shutdown applet](/img/2f/643ec964dba7643f91b1bd679a9284.png)
[C language] number guessing game + shutdown applet
随机推荐
Shell practice: one click start process, close process and view process status
Question 142 of Li Kou: circular linked list 2
[can I do your first project?] Detailed introduction and Simulation Implementation of gzip
在使用 VScode 进行代码格式化后,保存发现代码又变乱了,怎么办?vs去掉格式化
Which is a good fixed asset management system? What are the fixed asset management platforms?
-bash: ifconfig: command not found
js软件卸载提示表情跟随鼠标变化js特效
c语言实现strcmp、strstr、strcat、strcpy
Some libraries that can perform 2D or 3D triangulation
Towhee weekly model
Towhee 每周模型
Optimisation du serveur Cloud Huawei avec connexion clé
Flat style feedback form page
手机股票开户风险性大吗,安全吗?
Wacom firmware update error 123, digital board driver cannot be updated
CAN总线快速了解
【FLink】FLink Hash collision on user-specified ID “opt“. Most likely cause is a non-unique ID
Quanzhi f1c100s/f1c200s learning notes (13) -- lvgl transplantation
解决使用bert encoder出现的一系列问题
Several hole filling methods of point cloud (mesh) (1)