note 22322 added to function.mt-srand

From: Date: Thu, 13 Jun 2002 18:56:42 +0000
Subject: note 22322 added to function.mt-srand
Groups: php.notes 
Request: Send a blank email to php-notes+get-31826@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 -- http://www.php.net/manual/en/function.mt-srand.php http://master.php.net/manage/user-notes.php?action=edit+22322 http://master.php.net/manage/user-notes.php?action=delete+22322 http://master.php.net/manage/user-notes.php?action=reject+22322

« previous php.notes (#31826) next »