|
|
PHP srand() - Math Functions
|
Tutorials » Php »
|
Topic |
What is srand Function?
|
|
Explanation |
|
The "srand()" function seeds a random number to the random number generator rand(). This function should be called
only once, and should be called before the rand() function.
Syntax:
srand(seed)
In the above syntax "seed" is the optional value which can be a random number seed.
Example:
<?php
srand(mktime());
echo(rand());
?>
Result:
15067
In the above example the seed value is provided using the function mktime(), then a random number is generated.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|