Re: PHP 4.0 Bug #2201: uniqid strange values

From: Date: Tue, 31 Aug 1999 15:31:04 +0000
Subject: Re: PHP 4.0 Bug #2201: uniqid strange values
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-10386@lists.php.net to get a copy of this message
On Tue, Aug 31, 1999 at 12:14:25PM -0000, chrisvik@tapir.no wrote: > From: chrisvik@tapir.no > Operating system: RedHat 6.0 > PHP version: 4.0 Latest CVS (31/08/1999) > PHP Bug Type: Misbehaving function > Bug description: uniqid strange values > > In PHP3 and PHP4B1 uniqid() returned values like > 37c3afdea8412 > > In PHP4B2 and the latest CVS uniqid returnes values like > 37cbbbd3584b99.99999671 > (and ALWAYS the number 99999671 after the period) > > Is this intentional and expected of the future release of PHP4? > (I have to know because i have to restructure some DB-fields or find some other > ID-generator...) This is intentional. Notice that uniqid() does not make any promises with regard to the format of the returned string. If your application depends on a specific format, you should use a function which returns always the same format (i.e. md5()). The value of the combined LCG which you find at the end of the uniqid() return value, should never be the same within a period of (2^31 - 85) * (2^31 - 249) For example, the script for($i = 0; $i < 10; $i++) echo uniqid("")."\n"; produces the output 37cbf4c8aa5409.32011773 37cbf4c8ad2214.10714353 37cbf4c8ad2ec2.84566246 37cbf4c8ad3ac4.89409158 37cbf4c8ad4691.56120212 37cbf4c8ad5256.58456530 37cbf4c8ad5e12.00133011 37cbf4c8ad6a71.60144976 37cbf4c8ad7623.15287431 37cbf4c8ad81d1.25612660 I currently don't know of any circumstances where the lcg could fail (beside 16-bit platforms). -- Regards, Sascha Schumann Consultant

« previous php.dev (#10386) next »