How to use srand in PHP

This article describe about srand() Function in PHP.
  • 1486

srand() Function

This function is seeds the random number generator for rand().

This is must be called before any calls to rand() and called only once per script.

Syntax

srand(seed)

 

Parameter description
seed Option. seed number for random generator. skip a random value is used.

Example

<html>
<body>
<?php
srand(mktime());
echo(rand());
?>
</body>
</html>

Output

srand-php.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.