生成随机指定长度的字符串

/**
 *生成随机指定长度的字符串
*/
public static function stringGenerate($length){
$str = null;
$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789_abcdefghijklmnopqrstuvwxyz";
$max = strlen($strPol)-1;

for($i=0;$i<$length;$i++){
$str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
}
return $str;
}
原文地址:https://www.cnblogs.com/spectrelb/p/5999189.html