note 79528 added to function.microtime
| From: | egingell at sisna dot com | Date: | Sun, 02 Dec 2007 12:09:44 +0000 |
| Subject: | note 79528 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132731@lists.php.net to get a copy of this message | ||
> lloeki
> 26-Nov-2007 02:45
> You want some unique alphanum identifier? no need for some weird loop of sort.
>
> <?php
> $id = md5(microtime());
> ?>
microtime() does not return a unique value, the chances of two people getting the same result from
said function may be astronomical, but it is still possible. This is a much better alternative:
<?
$id = md5(uniqid('')); // Passing an empty string to uniqid() makes PHP < 5 happy.
?>
----
Server IP: 209.41.74.194
Probable Submitter: 207.224.195.213
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- https://master.php.net/note/edit/79528
Del: integrated -- https://master.php.net/note/delete/79528/integrated
Del: useless -- https://master.php.net/note/delete/79528/useless
Del: bad code -- https://master.php.net/note/delete/79528/bad+code
Del: spam -- https://master.php.net/note/delete/79528/spam
Del: non-english -- https://master.php.net/note/delete/79528/non-english
Del: in docs -- https://master.php.net/note/delete/79528/in+docs
Del: other reasons-- https://master.php.net/note/delete/79528
Reject -- https://master.php.net/note/reject/79528
Search -- https://master.php.net/manage/user-notes.php