GUID: The globally unique Identifier (globally unique identifier) is also known as the UUID (universally unique Identifier).
A GUID is a 128-bit numeric identifier produced by a particular algorithm that indicates the uniqueness of the product.
GUIDs are primarily used to assign identifiers that must be unique in a network or system that has multiple nodes, multiple computers, and more than one computer.
On the Windows platform, GUIDs are widely used in Microsoft products to identify objects such as registry keys, class and interface identifiers, databases, system catalogs, and so on.
Interface format:
The format of the GUID is "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", where each x is a 32-bit hexadecimal number in the range of 0-9 or a-f. For example, 6F9619FF-8B86-D011-B42D-00C04FC964FF is a valid GUID value.
Interface Description:
★guid are unique in space and time, guaranteeing that the numbers produced at different places at the same time are different.
★ No two computers in the world will generate duplicate GUID values.
★ When a GUID is required, it can be generated automatically by the algorithm and does not require an authoritative authority to manage it.
The length of the ★guid is fixed and relatively short, and is ideal for sorting, labeling, and storage.
For more information:
See the "Baidu Encyclopedia" section.
Generate a unique ID method
1.md5+ Time function
MD5 (timemt_rand(1,1000000));
Note: This method has a certain probability of recurrence
2.PHP built-in function uniqid ()
The Uniqid () function generates a unique ID based on the current time in microseconds.
W3school Reference Manual There is a sentence: "Due to system time, the ID generated by this function is not optimal." To generate an absolutely unique ID, use the MD5 () function.
The following method returns the result similar to: 5ddb650f-4389-f4a9-a100-501ef1348872
functionuuid () {if(function_exists(' Com_create_guid ' )) { return Com_create_guid (); } Else { Mt_srand( (Double)Microtime() * 10000);//Optional for PHP 4.2.0 and up. The random number sowing, 4.2.0 not need after. $charid=Strtoupper(MD5(uniqid(Rand(),true) ) );//generates a unique ID based on the current time (in microseconds). $hyphen=CHR(45);// "-" $uuid= './/chr (123)//"{"substr($charid, 0, 8).$hyphen.substr($charid, 8, 4).$hyphen.substr($charid, 12, 4).$hyphen.substr($charid, 16, 4).$hyphen.substr($charid, 20, 12 ); //. chr;//"}" return $uuid; }}
Description: Com_create_guid () is a PHP-generated unique ID method, which seems to have been lost after PHP5.
3. The official uniqid () reference manual has user-provided methods
The result is similar: {E2dfffb3-571e-6cfc-4b5c-9fedaaf2efd7}.
Public functionCreate_guid ($namespace= ' ') { Static $guid= ' '; $uid=uniqid("",true); $data=$namespace; $data.=$_server[' Request_time ']; $data.=$_server[' Http_user_agent ']; $data.=$_server[' Local_addr ']; $data.=$_server[' Local_port ']; $data.=$_server[' REMOTE_ADDR ']; $data.=$_server[' Remote_port ']; $hash=Strtoupper(Hash (' ripemd128 ',$uid.$guid.MD5($data))); $guid= ' {'.substr($hash, 0, 8). ‘-‘ .substr($hash, 8, 4). ‘-‘ .substr($hash, 12, 4). ‘-‘ .substr($hash, 16, 4). ‘-‘ .substr($hash, 20, 12). ‘}‘; return $guid;}
This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4803981.html
[PHP Learning Tutorial]005. Global Unique ID (GUID)