Since uniqid() provides a random string based on the value given, is it even possible, and if so, what are the chances of uniqid('foo') equalling uniqid('foo2')?
Since uniqid() provides a random string based on the value given, is it even
Share
uniqid()does not provide a random value based on the string.Per documentation:
fooandfoo2will only be used to prefix the value. For example, this code:would output:
As long as the prefix is different, the values won’t collide. However with the same prefix, a collision would be possible if the 2 requests are made at the same microsecond. If you are worried about collision, set the second parameter to
trueto add more entropy to your value.