w3resource

PHP: srand() function

Description

The srand() function seed the random number generator.

Version:

(PHP 4 and above)

Syntax:

srand(num)

Parameter:

Name Description Required /
Optional
Type
num Seed value. If omitted, a random value is used. Optional Integer

Return value:

No value is returned.

Example:

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

View the example in the browser

See also

PHP Function Reference

Previous: sqrt
Next: tan



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/srand.php