PHP function: uniqid ()

Source: Internet
Author: User
PHP function: uniqid () 1. function prototype

String uniqid ([string prefix [, bool more_entropy])

You can define the prefix and length of a unique ID.

2. version compatibility

PHP 3, PHP 4, PHP 5

III. basic function usage and examples

1. generate a unique ID

  

2. use the md5 () function to generate a unique ID.

  

Output: dfbc5c8c6438de075da28b3c8a413fd0

3. multiple unique IDs are generated, because they are measured in microseconds.

  

Output:

4bfd0e375108b

4bfd0e3753981

4bfd0e3753983

According to the generated results, unique IDs are sorted.

Use the uniqid () function to generate a unique ID. This function can be used to generate both temporary IDs and permanent unique IDs (stored in the database). For more information, see The PHP Manual.

In addition, the unique value between different systems can be implemented on the two parameters of uniqid (). The first parameter is the prefix, and different servers can be specified on different servers;

The second parameter returns more entropy. if it is true, 23 characters are returned.

Reprinted from: http://www.helloweba.com/view-blog-107.html

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.