note 65913 added to function.microtime

From: Date: Wed, 10 May 2006 03:29:35 +0000
Subject: note 65913 added to function.microtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-111014@lists.php.net to get a copy of this message
In RE: Eric Pecoraro's comment below: I've always found a much much simpler (and faster imho) way of doing this is just stamping posix_getpid() onto the back of microtime() and md5()'ing the whole thing, then use substr to shorten to the required length, eg: <?php // punch out a 20-byte random ID print substr(md5(microtime() . posix_getpid()), 0, 20); ?> I've never had a duplicate ID generated by this, and it's been in some pretty high-demand fast loops. ---- Server IP: 203.202.10.60 Probable Submitter: 203.206.163.153 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.microtime.php Edit -- http://master.php.net/note/edit/65913 Del: integrated -- http://master.php.net/note/delete/65913/integrated Del: useless -- http://master.php.net/note/delete/65913/useless Del: bad code -- http://master.php.net/note/delete/65913/bad+code Del: spam -- http://master.php.net/note/delete/65913/spam Del: non-english -- http://master.php.net/note/delete/65913/non-english Del: in docs -- http://master.php.net/note/delete/65913/in+docs Del: other reasons-- http://master.php.net/note/delete/65913 Reject -- http://master.php.net/note/reject/65913 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111014) next »