• php代码片段


    1.复杂密码检查

            if($account == $password)//密码不能和帐号相同
            {
                return false;
            }
            if(strlen($password) < 8)//密码长度不能小于8位
            {
                return false;
            }
    /*        if(substr_count($account, $password) > 0)//密码不能是帐号的一部分
            {
                return false;
            }
    
            if(substr_count($password, $account) > 0)//密码中不能包含完整的帐号
            {
                return false;
            }
    
            if(count(array_unique(str_split($password,1))) < 4)//密码至少包含四个不同字符
            {
                return false;
            }
            */
            if(!preg_match('/[A-Za-z0-9_W]{8,}/',$password)
                || !preg_match('/[A-Z]{1}/',$password)
                || !preg_match('/[a-z]{1}/',$password)
                || !preg_match('/[0-9]{1}/',$password)
                || !preg_match('/[W_]{1}/',$password)
            )
            {
                return false;
            }
    
            return true; 
    

    2. php正则匹配中文(不止中文)

    <?php
    
    $a = [];
    
    preg_match("![x7f-xff]+!",'你妹的', $a);//加号一定要,不然只能匹配中文字符的三分之一
    var_dump($a);
  • 相关阅读:
    jquery 選擇器
    jquery 語法
    jQuery 簡介
    js cookies
    基本数据类型
    python----编程语言介绍
    Python---计算机基础
    复习os模块常用的一些操作
    模块的初识
    模块和包
  • 原文地址:https://www.cnblogs.com/flytome/p/5600833.html
Copyright © 2020-2023  润新知