Course Recommendation:

PHP uniqid() Function

Definition and Usage

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

SyntaxDescriptionuniqid(more_entropy,
) Parameter
Description Description
more_entropy Optional. Specifies a prefix for the ID. This parameter is very useful if two scripts generate IDs at the same microsecond.

Optional. Specifies more entropy at the end of the return value.

If Description prefix more_entropy is set to true, it is 23 characters long. If the parameter is empty, the returned string is 13 characters long. If

If more_entropy If the parameter is set to true, an additional entropy is added to the end of the return value (using a combination linear congruential generator), which makes the uniqueness of the result better.

Return Value

Returns a unique identifier as a string.

Tips and Comments

Note:Since the ID generated by this function is based on system time, it is not the best. If you need to generate an absolutely unique ID, please use the md5() function (please refer to the string function reference).

Example

<?php
echo uniqid();
?>

Output similar to:

4415297e3af8c