/*随机天生字符串函数random
$length天生字符串的长度
*/
function random($length) {
$hash = '';
$chars = '0123456789';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}echo random(6);扫一扫,关注设计动量,随时参与互动。
$length天生字符串的长度
*/
function random($length) {
$hash = '';
$chars = '0123456789';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}echo random(6);扫一扫,关注设计动量,随时参与互动。

- 我要评论