Home > php教程 > php手册 > php生成随机密码的自定义函数(转载分享),php自定义

php生成随机密码的自定义函数(转载分享),php自定义

WBOY
Release: 2016-06-13 09:10:15
Original
1101 people have browsed it

php生成随机密码的自定义函数(转载分享),php自定义

php生成随机密码的自定义函数

发布时间:2015-03-24编辑:脚本学堂
php生成随机密码的自定义函数  

生成一个随机密码的函数,生成的密码为小写字母与数字的随机字符串,长度可自定义。
 

复制代码代码如下: /*
 * php自动生成新密码自定义函数(带实例演示)
      适用环境: PHP5.2.x  / mysql 5.0.x
       代码作者: xujiajay
       联系方式: xujiaphp@gmail.com
* */
function genPassword($min = 5, $max = 8)  
{  
    $validchars="abcdefghijklmnopqrstuvwxyz123456789";  
    $max_char=strlen($validchars)-1;  
    $length=mt_rand($min,$max);  
    $password = "";  
    for($i=0;$i    {  
        $password.=$validchars[mt_rand(0,$max_char)];  
    }  
        return $password;  
    }  
    echo "新密码:".genPassword()."
";  
    echo "新密码:".genPassword(5,10)."
";
?>

 本文转自脚本学堂 http://www.jbxue.com
查看原文:php生成随机密码的自定义函数

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template