note 22322 deleted from function.mt-srand by torben
| From: | torben@php.net | Date: | Thu, 13 Jun 2002 19:01:35 +0000 |
| Subject: | note 22322 deleted from function.mt-srand by torben | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-31828@lists.php.net to get a copy of this message | ||
to : l_rossato@libero.it
doing ...
list($usec,$sec)=explode(" ",microtime());
$unique = mt_srand($sec * $usec);
theoretiaclly, makes just as much sense as
list($usec,$sec)=explode(" ",microtime());
$unique = $usec + 0;
Once every while, depending on the microsecond resolution of your computer, the millisecond value
will be a zero (0), and as I hope you know, in mathematics, any number multiplied by a zero becomes
a zero itself.
(x * 0 = 0)
In real life, on a good machine, with a resolution to 1 million miliseconds per each second (i.e:
Win2k server), you will be reduplicating your unique ID each million's ID issued. This means if
you use it as your cookie encryption algorithm or a visitor ID, you will not exceed some million
instances.
Futhermore, if that would be for a software development that you re-distribuite, installed on some
weird old PC, where resolution can be as small as 100 milliseconds per second - a code with this
uniqueness algorithm just wouldn't last any long.
Good Luck,
Maxim Maletsky
maxim@php.net
PHPBeginner.com