PHP srand() Function

Definition

The srand() function seeds the random number generator (rand()).

Syntax

PHP srand() Function has the following syntax.

srand(seed);

Parameter

Parameter Description
seed Optional. Specifies the seed value

Return

None

Example

Seed the random number generator:


<?php
srand(mktime());
echo(rand());
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions