Easy Tutorial
❮ Func Filesystem Symlink Func Ftp Pasv ❯

PHP uniqid() Function

PHP Misc Reference Manual

Example

Generate a unique ID:


Definition and Usage

The uniqid() function generates a unique ID based on the current time in microseconds.

Note: Due to being based on the system time, the IDs generated by this function are not optimal. For generating absolutely unique IDs, use the md5() function.


Syntax

Parameter Description
prefix Optional. Specifies a prefix for the unique ID. This is useful if two scripts generate IDs at exactly the same microsecond.
more_entropy Optional. Specifies additional entropy at the end of the return value. This makes the result more unique. When set to TRUE, the returned string is 23 characters long. By default, it is FALSE, and the returned string is 13 characters long.

Technical Details

Return Value: Returns the unique identifier as a string.
PHP Version: 4+
--- ---
Changelog: In PHP 5.0, the prefix parameter became optional. <br> <br>In PHP 4.3.1, the 114 character length limit for prefix was increased.
--- ---
❮ Func Filesystem Symlink Func Ftp Pasv ❯