您的位置:首页 > 编程语言 > PHP开发

php生成随机字符串

2019-05-24 18:56 246 查看

php生成随机字符串

/**
* @Title: create_randomstr
* @Description: 获取随机字符串
* @param @param number $lenth  字符长度
*/
function create_randomstr($lenth = 8) {
$str = '';
$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
$max = strlen($strPol)-1;
for($i=0;$i<$lenth;$i++){
$str.=$strPol[rand(0,$max)];
}
return $str;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: