PHP uniqid()Functions
Definition and Usage
The uniqid() function generates a unique ID based on the current time in microseconds.
Note:Since it is based on system time, the ID generated by this function is not optimal. To generate an absolutely unique ID, use themd5()function.
Syntax
uniqid(prefix,more_entropy)
| Parameters | Description |
|---|---|
| prefix | Optional. Specifies a prefix for the unique ID. This parameter is useful if two scripts happen to generate IDs at the same microsecond. |
| more_entropy | Optional. Specifies more entropy at the end of the return value. This makes the result more unique. When set to TRUE, the returned string is 23 characters. Default is FALSE, and the returned string is 13 characters. |
Technical Details
| Return Value: | Returns the unique identifier as a string. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | In PHP 5.0,prefixthe parameter became optional. In PHP 4.3.1,prefixthe 114-character length limit of the prefix was increased. |
PHP Misc Reference Manual Other Extensions