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.
Generate a unique ID:
<?php echo uniqid ( ) ; ?>
Try it yourself
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. |
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.
Returns a unique identifier as a string.