Generate a unique ID:
<?phpecho uniqid();?>The uniqid() function generates a unique ID based on the current time in microseconds.
Note: The ID generated by this function is not optimal because it is based on system time. To generate an absolutely unique ID, use the md5() function.
uniqid( prefix,more_entropy )
parameter | describe |
---|---|
prefix | Optional. Specifies the prefix for unique IDs. 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 will make the results more unique. When set to TRUE, the returned string is 23 characters. The default is FALSE, and the returned string is 13 characters. |
Return value: | Returns the unique identifier as a string. |
---|---|
PHP version: | 4+ |
Update log: | In PHP 5.0, the prefix parameter becomes optional. In PHP 4.3.1, the 114-character length limit for prefix was increased. |