PHP srand()Function

PHP Math 参考手册PHP Math Reference Manual

Examples

Seed the random number generator:

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

Run example »

Definition and Usage

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

Tip:As of PHP 4.2.0, the random number generator is automatically seeded, so there is no need to use this function.


Syntax

srand(seed);

Parameters Description
seed Optional. Specifies the seed value.

Technical Details

Return value: None.
Return type: -
PHP Version: 4+
PHP Changelog: PHP 4.2.0: The random number generator is automatically seeded.


PHP Math 参考手册PHP Math Reference Manual Other Extensions