Re: Re: Unique ID on 5.0.4 (Windows)
| From: | Chris | Date: | Thu, 22 Sep 2005 14:58:02 +0000 |
| Subject: | Re: Re: Unique ID on 5.0.4 (Windows) | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222983@lists.php.net to get a copy of this message | ||
Jasper Bryant-Greene wrote:
Chris wrote:Any particular reason why you used sha1() in there? Thanks alot, ChrisDavid Robley wrote:$unique_id = sha1( uniqid( mt_rand(), true ) ); That unique ID will be based on the current time in microseconds prefixed by a random number generated by the Mersenne Twister. That is *extremely* unlikely to duplicate, even at the same microsecond. Ok, thanks, That looks like it will work for me.Chris wrote:If two requests generate and ID at the same microsecond then the ID will duplicate, and that will not work for me.Pretty soon I'm going to be needing to generate a unique identifier in a script. I'm looking into how to go about doing it now.Have you looked at uniqid() ? http://php.net/uniqid