Home > PHP > Function > Misc. > uniqid()

uniqid()

uniqid - Generate a unique ID

Syntax

string uniqid (string $prefix, bool $more_entropy)

Arguments

  • prefix - Can be useful, for instance, if you generate identifiers simultaneously on several hosts that might happen to generate the identifier at the same microsecond. With an empty prefix, the returned string will be 13 characters long. If more_entropy is TRUE, it will be 23 characters.
  • more_entropy - If set to TRUE, uniqid() will add additional entropy (using the combined linear congruential generator) at the end of the return value, which should make the results more unique.

Description

Gets a prefixed unique identifier based on the current time in microseconds.

Version

PHP 4, 5

Return value

Returns the unique identifier, as a string.