Change language

PHP Uniqid () Function

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

    Shop

    Gifts for programmers

    Best laptop for Excel

    $
    Gifts for programmers

    Best laptop for Solidworks

    $399+
    Gifts for programmers

    Best laptop for Roblox

    $399+
    Gifts for programmers

    Best laptop for development

    $499+
    Gifts for programmers

    Best laptop for Cricut Maker

    $299+
    Gifts for programmers

    Best laptop for hacking

    $890
    Gifts for programmers

    Best laptop for Machine Learning

    $699+
    Gifts for programmers

    Raspberry Pi robot kit

    $150

    Latest questions

    PythonStackOverflow

    Common xlabel/ylabel for matplotlib subplots

    1947 answers

    PythonStackOverflow

    Check if one list is a subset of another in Python

    1173 answers

    PythonStackOverflow

    How to specify multiple return types using type-hints

    1002 answers

    PythonStackOverflow

    Printing words vertically in Python

    909 answers

    PythonStackOverflow

    Python Extract words from a given string

    798 answers

    PythonStackOverflow

    Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

    606 answers

    PythonStackOverflow

    Python os.path.join () method

    384 answers

    PythonStackOverflow

    Flake8: Ignore specific warning for entire file

    360 answers


    Wiki

    Python | How to copy data from one Excel sheet to another

    Common xlabel/ylabel for matplotlib subplots

    Check if one list is a subset of another in Python

    How to specify multiple return types using type-hints

    Printing words vertically in Python

    Python Extract words from a given string

    Cyclic redundancy check in Python

    Finding mean, median, mode in Python without libraries

    Python add suffix / add prefix to strings in a list

    Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

    Python - Move item to the end of the list

    Python - Print list vertically