gongzhonghao.png
扫码关注我们
最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

php生出随机字符串的示例详解分析

来源:http://erdangjiade.com/topic/2174.html 你好,世界。 2017-09-25 22:42浏览(18)

使用PHP开发应用程序,尤其是网站程序,常常需要生成随机密码,而本文收集整理了生成随机字符串的方法

 generateRandomString( = 10 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' = '' ( = 0;  < ; ++ .= [(0, () - 1 generateRandomString(20);
/**
 * 随机生成字符串
 * @param int $length
 * @return null|string
 */private static function getRandChar($length = 8){
    $str = null;
    $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
    $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){
        $str.=$strPol[rand(0,$max)]; //rand($min,$max)生成介于min和max两个数之间的一个随机整数
    } return $str;
}

以上就是php生出随机字符串的方法介绍的详细内容,更多请关注二当家的素材网其它相关文章!

评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2