/**
* 生成随机字符串
* @author 宁佳兵 <meilijing.ning@foxmail.com>
* @param int $length
* @return string
*/
function createNonceStr($length = 16) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$str = "";
for ($i = 0; $i < $length; $i++) {
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $str;
}
PHP 生成随机字符串
点赞
收藏