Miscellaneous Functions Library: Uniqid

Source: Internet
Author: User
Keywords PHP Chinese function Manual uniqid miscellaneous functions Library
Tags aliyun function functions html http php php chinese function manual php3

Uniqid

(PHP3, PHP4)

Uniqid---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; produce a unique ID

Syntax: int uniqid (String prefix [, Boolean LCG])

Description:

Uniqid () returns a unique identifier for the current time of one out of 10,000 seconds, and if you produce identifier on several hosts at the same time, it can happen to generate identifier on the same one out of 10,000 second, and then you can use parameter prefix, Parameter prefix can be up to 114 characters long.

If the LCG parameter is set to True,uniqid () the additional "combined LCG" will be added after the return value, which makes the result even more unique.

Empty prefix, the returned string will be 13 characters long and, if LCG is true, 23 characters long.

Note: parameter LCG only works in PHP4 and PHP3.0.13 and newer editions

If you need a unique identifier or tag, and you intend to publish the tag via receptacle (for example, session cookies), you can use this:

Example:

<?php

$token = MD5 (Uniqid ("")); No random portion

$better _token = MD5 (Uniqid (rand ())); Decoupled, difficult to guess

?>

This will produce a 32-character long identifier.

Related Article

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.