You are here : phpmathrand

rand() - math

If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 5 and 15 (inclusive), for example, use rand(5, 15).

Parameters :
  • min - The lowest value to return (default: 0)
  • max - The highest value to return (default: getrandmax())

  • Syntax

    int rand(void)
    
    int rand ( int $min , int $max )


    Example

    <?phpecho rand() . "\n";echo rand() . "\n";echo rand(5, 15);?>


    Output / Return Value


    Limitations


    Alternatives / See Also


    Reference