Uniqid () function and microtime () function

Source: Internet
Author: User

The Uniqid () function generates a unique ID based on the current time in microseconds.
Grammar

Uniqid (prefix,more_entropy)


Parameter description
prefix is optional. Specify a prefix for the ID. This parameter is useful if two scripts generate IDs exactly in the same microsecond.
More_entropy is optional. Specify more entropy at the end of the return value

Description

If the prefix parameter is empty, the returned string has 13 string lengths. 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 combination line with the remainder generator), which results in better uniqueness.
return value

Returns a unique identifier in the form of a string.
Hints and Notes

Note: The ID generated by this function is not optimal due to system time. To generate an absolutely unique ID, use the MD5 () function (find in the string function Reference).

Definition and usage

The Microtime () function returns the current Unix timestamp and the number of microseconds.

Grammar
Microtime (Get_as_float)
Parameters Description
Get_as_float If the Get_as_float parameter is given and its value is equivalent to TRUE, the function returns a floating-point number.

echo Microtime (ture); echo "<br>";

Echo Uniqid (); echo "<br>";

echo MD5 (Uniqid (Microtime (ture), ture));

The output is:

1422072861.4654c31c1d7044c4138288389622ae5810434975f17fb7d

Uniqid () function and microtime () function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.