欢迎各位兄弟 发布技术文章
这里的技术是共享的
//判断是否包含 大小写(大写小写) 数字 特殊字符当中的三种
function _judge_three_char($password)
{
$one = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$two = "abcdefghijklmnopqrstuvwxyz";
$three = '0123456789';
$four = "~!@#$%^&*()_+`-={}|:\"<>?[]\;',./";
$password_arr = str_split($password);
$num = 0;
foreach($password_arr as $key=>$value)
{
if(_strexists($one,$value)){
$num++;
break;
}
}
foreach($password_arr as $key=>$value)
{
if(_strexists($two,$value)){
$num++;
break;
}
}
foreach($password_arr as $key=>$value)
{
if(_strexists($three,$value)){
$num++;
break;
}
}
foreach($password_arr as $key=>$value)
{
if(_strexists($four,$value)){
$num++;
break;
}
}
return $num>=3;
}
2) 第二个自己亲自做的php
$bool_num = 0;
if (preg_match('/\d/', $pw)) {
$bool_num = $bool_num + 1;
}
if (preg_match('/[a-z]/', $pw)) {
$bool_num = $bool_num + 1;
}
if (preg_match('/[A-Z]/', $pw)) {
$bool_num = $bool_num + 1;
}
if (preg_match("/[~!@#$%^&*()\_+`\-=\[\]\|\\\\{};':\",\.\/<>\?]/", $pw)) {
$bool_num = $bool_num + 1;
}
if ($bool_num < 3) {
form_set_error('pw_new', '密码必须有大写,小写,数字,符号这四种中的三种!');
}
3) 第三个自己亲自做的 javascript (js)
function _test_three_in_four(str){
var bool_num = 0;
var r = /\d/g;
if(r.test(str)){
bool_num = bool_num+1;
}
r = /[a-z]/g;
if(r.test(str)){
bool_num = bool_num+1;
}
r = /[A-Z]/g;
if(r.test(str)){
bool_num = bool_num+1;
}
r = /[~!@#$%^&*()\_+`\-=\[\]\|\\\\{};':\",\.\/<>\?]/;
if(r.test(str)){
bool_num = bool_num+1;
}
return bool_num >= 3;
}
_test_three_in_four(pwd_val);