Current Location: Home> Function Categories> uniqid

uniqid

Generate a unique ID
Name:uniqid
Category:Miscellaneous
Programming Language:php
One-line Description:Generate a unique ID.

Definition and usage

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

Tip: Because it is based on system time, the ID generated by this function is not optimal. To generate an absolutely unique ID, use the md5() function.

Example

Generate a unique ID:

 <?php
echo uniqid ( ) ;
?>

Try it yourself

grammar

 uniqid ( prefix , more_entropy )
parameter describe
prefix

Optional. Specify a prefix for ID.

This parameter is useful if both scripts happen to generate IDs in the same microseconds.

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

illustrate

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

If the more_entropy parameter is set to true, additional entropy is added at the end of the return value (using a combined linear congruent generation program), which makes the result uniqueness better.

Return value

Returns a unique identifier as a string.

Similar Functions
Popular Articles