PHP uniqid( ) Function Last Updated : 24 Sep, 2024 Comments Improve Suggest changes Like Article Like Report The uniqid() function in PHP generates a unique identifier based on the current time in microseconds. It creates a string that is highly unlikely to duplicate during execution, making it useful for generating unique tokens, filenames, or session IDs. Optional parameters enhance uniqueness.Syntax uniqid($prefix, $more_entropy) Parameters Used: The uiqid() function in PHP accepts two parameters. $prefix : It is an optional parameter which specifies a prefix to the unique id. It must be string.$more_entropy : It is an optional parameter which specifies more entropy at the end of the return value which makes the id more unique.The default value is FALSE, which returns 13 characters long string whereas when it is set to TRUE, the return string is 23 characters long.Return Value: It returns timestamp based unique identifier as a string.Errors And Exceptions: The uniqid() function tries to create unique identifier, but it does not guarantee 100% uniqueness of return value.Since most systems adjust system clock by NTP or like, system time is changed constantly. Therefore, it is possible that this function does not return unique ID for the process/thread.Example: In this example we generates a unique identifier using the uniqid() function. The output is a string based on the current time in microseconds, which helps create unique IDs for various purposes. php <?php // generating unique id echo uniqid(); ?> Output66f28d46f08d6Example 2: In this example we generates a unique identifier using the uniqid() function with a prefix "gfg". The result is a unique string starting with "gfg", followed by a timestamp-based unique identifier. php <?php // generating unique id with prefix gfg $myuid = uniqid('gfg'); echo $myuid; ?> Outputgfg66f28d652e57a Comment More infoAdvertise with us Next Article PHP uniqid( ) Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP rand() Function In this article, we will see how to get the random number using the rand() function in PHP, along with knowing its implementation through the example. The rand() is an inbuilt function in PHP used to generate a random number ie., it can generate a random integer value in the range [min, max]. Syntax 2 min read PHP urlencode() Function The urlencode() function is an inbuilt PHP function used to encode the URL. This function returns a string consisting of all non-alphanumeric characters exceptâ_. It is replaced by the percent (%) sign, followed by two hex digits and spaces encoded as plus (+) signs. Syntax:string urlencode( $input 1 min read PHP array_unique() Function The PHP array_unique() function removes duplicate values from an array, preserving the first occurrence of each value and reindexing the array with keys preserved. It's useful for filtering out redundant data and ensuring a collection of unique elements within an array. Syntaxarray array_unique($arr 2 min read PHP mt_rand( ) Function While working with algorithms we often come across situations when we need to generate random integers. The most common way to generate random numbers is using Mersenne Twister. The Mersenne Twister is a pseudorandom number generator which got its name derived from the fact that its period length is 2 min read PHP sscanf() Function The PHP sscanf() is an inbuilt function in PHP where the input string is parsed according to the specified or a particular pattern, along with comparing & matching any whitespace in between the format string & input string, which means, even the tab(\t) will be comparing & matches a sing 2 min read Like