The uniqid() function takes a prefix and more_entropy as parameters and returns a unique identifier based on a timestamp as a string.
Syntax:uniqid ($prefix, $more_entropy)
Parameters used:The uiqid() function in PHP takes two parameters.
$prefix: This is an optional parameter which specifies the prefix for the unique identifier. $more_entropy: This is an optional parameter that gives more entropy at the end of the return value, making the identifier more unique. The default is - FALSE, which returns a string that is 13 characters long, whereas TRUE returns a string that is 23 characters long. Return Value:Returns a unique identifier based on a timestamp in as a string.
Errors and exceptions The uniqid() function tries to create a unique identifier, but it does not guarantee 100% uniqueness of the return value. Since most systems set the system clock via NTP or the like, the system time is constantly changing. Therefore, it is possible that this function does not return a unique identifier for the process / thread. The following programs illustrate the uniqid() function:
Program 1:
// generate a unique identifier
echo
uniqid();
?>
Output:3b2c662647f18
Program 2:
// generate a unique identifier using pefix gfg
$myuid
= uniqid (gfg);
echo
$myuid
;
?>
Output:gfg5b2b451823970
Program 3:
// generate a unique identifier using pefix gfg
// and higher entropy
$myuid
= uniqid (gfg, true);
echo
$myuid
;
?>
Output:gfg5b2b4555ab6bd7.27884925
Link: http: // php .net / manual / en / function.uniqid.php