PHP 判断密码强度

时间:2019-04-15
本文章向大家介绍PHP 判断密码强度,主要包括PHP 判断密码强度使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
 
           $score = 0;
           if(preg_match("/[0-9]+/",$str))
           {
              $score ++; 
           }
           if(preg_match("/[0-9]{3,}/",$str))
           {
              $score ++; 
           }
           if(preg_match("/[a-z]+/",$str))
           {
              $score ++; 
           }
           if(preg_match("/[a-z]{3,}/",$str))
           {
              $score ++; 
           }
           if(preg_match("/[A-Z]+/",$str))
           {
              $score ++; 
           }
           if(preg_match("/[A-Z]{3,}/",$str))
           {
              $score ++; 
           }
           if(preg_match("/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]+/",$str))
           {
              $score += 2; 
           }
           if(preg_match("/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]{3,}/",$str))
           {
              $score ++ ; 
           }
           if(strlen($str) >= 10)
           {
              $score ++; 
           }
           echo "<br>";
           echo $score;