我尝试用php代码生成随机(3个数字)数字,但当我尝试返回值时,它不会';不起作用


I try to generate random (3 numbers) numbers with the php code, but when I try to return the value it doesn't work

这是我的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();
?>
function generate_random_3() {
  return rand(100,999);
}
echo generate_random_3();

任一方式。。。。

$number1 = rand(0,365);
$number2 = rand(0,365);
$number3 = rand(0,365);

echo $number1 . " " . $number2 . " " . $number3;