note 90215 added to function.srand
| From: | harmen at no dot spam dot rdzl dot nl | Date: | Fri, 10 Apr 2009 17:53:52 +0000 |
| Subject: | note 90215 added to function.srand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153052@lists.php.net to get a copy of this message | ||
To generate a random number which is different every day, I used the number of days after unix epoch
as a seed:
<?php
srand(floor(time() / (60*60*24)));
echo rand() % 100;
?>
My provider upgraded the php server recently, and calling srand(seed) does not seem to set the seed
anymore. To let srand set the seed, add the following line to your .htaccess file
php_value suhosin.srand.ignore 0
Kudos to doc_z (http://www.webmasterworld.com/php/3777515.htm)
Harmen
----
Server IP: 64.71.164.2
Probable Submitter: 81.210.179.2
----
Manual Page -- http://www.php.net/manual/en/function.srand.php
Edit -- https://master.php.net/note/edit/90215
Del: integrated -- https://master.php.net/note/delete/90215/integrated
Del: useless -- https://master.php.net/note/delete/90215/useless
Del: bad code -- https://master.php.net/note/delete/90215/bad+code
Del: spam -- https://master.php.net/note/delete/90215/spam
Del: non-english -- https://master.php.net/note/delete/90215/non-english
Del: in docs -- https://master.php.net/note/delete/90215/in+docs
Del: other reasons-- https://master.php.net/note/delete/90215
Reject -- https://master.php.net/note/reject/90215
Search -- https://master.php.net/manage/user-notes.php