这是我的PHP脚本: 当我尝试将值返回$ total和echo函数generate_random_3之后,在某些情况下它不生成任何数字,请帮助
<?php
function generate_random_3(){
for($x=0; $x<3; $x++){
$random[] = rand(1, 9);
}
list($first, $second, $third) = $random;
if($first!=$second AND $first!=$third AND $second!=$third AND $first!=0){
$total = $first.$second.$third;
return $total;
}else{
generate_random_3();
}
}
echo generate_random_3();
?>
答案 0 :(得分:1)
function generate_random_3() {
return rand(100,999);
}
echo generate_random_3();
答案 1 :(得分:0)
$number1 = rand(0,365);
$number2 = rand(0,365);
$number3 = rand(0,365);
echo $number1 . " " . $number2 . " " . $number3;