Answers for "add random number in variable php"

PHP
8

php random number

// $min and $max are optional
rand($min,$max);
Posted by: Guest on April-14-2020
-1

php random number

<?php
// src/Controller/LuckyController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;

class LuckyController
{
    public function number(): Response
    {
        $number = random_int(0, 100);

        return new Response(
            '<html><body>Lucky number: '.$number.'</body></html>'
        );
    }
}
Posted by: Guest on March-30-2022

Browse Popular Code Answers by Language