You are here: Re: [PHP] Re: Unique ID on 5.0.4 (Windows) « PHP « IT news, forums, messages
Re: [PHP] Re: Unique ID on 5.0.4 (Windows)

Posted by Chris on 10/21/82 11:27

Jasper Bryant-Greene wrote:

> Chris wrote:
>
>> David Robley wrote:
>>
>>> Chris wrote:
>>>
>>>>
>>>> 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
>>>
>>>
>> If two requests generate and ID at the same microsecond then the ID
>> will duplicate, and that will not work for me.
>
>
> $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.

Any particular reason why you used sha1() in there?

Thanks alot,
Chris

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация