PHP srand() Function

Definition and Usage

The srand() function seeds the random number generator.

Syntax

srand(Seed)
Parameter Description
Seed Optional. Use seed to seed the random number generator.

Description

Starting from PHP 4.2.0 version,Seed Optional. Use seed to seed the random number generator.

Tips and Comments

Note:Since PHP 4.2.0, srand() or mt_srand() The function seeds the random number generator, which is now automatically completed.

Example

In this example, we will seed the random number generator:

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

Output:

23054