PHP rand() Function – Generating Random Integers
The PHP rand() function returns a pseudo‑random integer within a given range, defaulting to 0 through getrandmax() when no parameters are supplied, and includes details on its parameters, return value, and usage examples.
The PHP rand() function returns a pseudo‑random integer between a specified minimum and maximum, or between 0 and getrandmax() when no arguments are given.
Parameters
min – The lowest value to return (default 0).
max – The highest value to return (default getrandmax()).
Return value
A pseudo‑random integer between min (or 0) and max.
Example
<?php
echo rand();
"
"; // 7771
echo rand();
"
"; // 22264
echo rand(5,15);
"
"; // 11
?>Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
