How to use of uniqid function to generate a random, unique, alphanumeric string in php?

The uniqid() function generates a unique ID based on the microtime (the current time in microseconds) in PHP. Generate a random, unique, alphanumeric string in PHP

1. Code:

  <?php
echo uniqid();
?> 

Syntax:

uniqid(prefix,more_entropy) 

Parameter Values

ParameterDescription
prefixOptional. Specifies a prefix to the unique ID (useful if two scripts generate ids at exactly the same microsecond)
more_entropyOptional. Specifies more entropy at the end of the return value. This will make the result more unique. When set to TRUE, the return string will be 23 characters. Default is FALSE, and the return string will be 13 characters long

2. Example:

Input:

uniqid()

Output:

630c6c2321d9f