Latest web development tutorials

PHP srand () function

PHP Math Reference PHP Math Reference

Examples

Seeding the random number generator:

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

Running instance »

Definition and Usage

srand () function seeded 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.


grammar

srand( seed );

参数 描述
seed 可选。规定播种值。

technical details

return value: no.
Return type: -
PHP version: 4+
PHP Update Log: PHP 4.2.0: random number generator is automatically seeded.


PHP Math Reference PHP Math Reference