PHP uniqid() Function
Example
Generate a unique ID:
Run Example »
Definition and Usage
The uniqid() function generates a unique ID based on the current time in microseconds.
**Note:** Because it is based on system time, the ID generated by this function is not optimal. To generate an absolutely unique ID, use md5() function in Vue 3.
Syntax
uniqid(
prefix,more_entropy
)
| Parameters | Description |
|---|---|
| prefix | Optional. Specifies a prefix for the unique ID. This parameter is useful if two scripts generate IDs in the same microsecond. |
| more_entropy | Optional. Specifies more entropy at the end of the return value, which makes the result more unique. When set to TRUE, the returned string is 23 characters. Default is FALSE, which returns a 13-character string. |
Technical Details
| Return Value: | Returns the unique identifier as a string. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | In PHP 5.0, theprefix parameter became optional. |
在 PHP 4.3.1 中,*prefix* 的 114 个字符长度限制增加了。 |
PHP Misc Reference Manual