X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP srand() Function

PHP Math Reference PHP Math Reference

Example

Seed the random number generator:

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

Run example »

Definition and Usage

The srand() function seeds the random number generator (rand()).

Tip: From PHP 4.2.0, the random number generator is seeded automatically and there is no need to use this function.


Syntax

srand(seed);

Parameter Description
seed Optional. Specifies the seed value

Technical Details

Return Value: None
Return Type: -
PHP Version: 4+
PHP Changelog: PHP 4.2.0: Random number generator is now seeded automatically


PHP Math Reference PHP Math Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook