生成固定位数的随机数
function
generate_code(
$length
= 4) {
$min
= pow(10 , (
$length
- 1));
$max
= pow(10,
$length
) - 1;
return
rand(
$min
,
$max
);
}
function
generate_code(
$length
= 4) {
$min
= pow(10 , (
$length
- 1));
$max
= pow(10,
$length
) - 1;
return
rand(
$min
,
$max
);
}
转载于:https://www.cnblogs.com/handongyu/p/5756170.html