PHP srand() Function
In this chapter you will learn:
- Definition for PHP srand() Function
- Syntax for PHP srand() Function
- Parameter for PHP srand() Function
- Return for PHP srand() Function
- Example - Seed the random number generator
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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP tan() Function
- Syntax for PHP tan() Function
- Parameter for PHP tan() Function
- Return for PHP tan() Function
- Example - Return the tangent of different numbers
Home » PHP Tutorial » PHP Math Functions