note 95001 added to function.uniqid

From: Date: Tue, 08 Dec 2009 02:18:57 +0000
Subject: note 95001 added to function.uniqid
Groups: php.notes 
Request: Send a blank email to php-notes+get-163705@lists.php.net to get a copy of this message
For the record, the underlying function to uniqid() appears to be roughly as follows: $m=microtime(true); sprintf("%8x%05x\n",floor($m),($m-floor($m))*1000000); In other words, first 8 hex chars = Unixtime, last 5 hex chars = microseconds. This is why it has microsecond precision. Also, it provides a means by which to reverse-engineer the time when a uniqid was generated: date("r",hexdec(substr(uniqid(),0,8))); Increasingly as you go further down the string, the number becomes "more unique" over time, with the exception of digit 9, where numeral prevalence is 0..3>4>5..f, because of the difference between 10^6 and 16^5 (this is presumably true for the remaining digits as well but much less noticeable). ---- Server IP: 208.69.120.55 Probable Submitter: 174.46.204.210 ---- Manual Page -- http://www.php.net/manual/en/function.uniqid.php Edit -- https://master.php.net/note/edit/95001 Del: integrated -- https://master.php.net/note/delete/95001/integrated Del: useless -- https://master.php.net/note/delete/95001/useless Del: bad code -- https://master.php.net/note/delete/95001/bad+code Del: spam -- https://master.php.net/note/delete/95001/spam Del: non-english -- https://master.php.net/note/delete/95001/non-english Del: in docs -- https://master.php.net/note/delete/95001/in+docs Del: other reasons-- https://master.php.net/note/delete/95001 Reject -- https://master.php.net/note/reject/95001 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163705) next »