A UUID is a number generated on a single machine that guarantees that all machines in the same space-time are unique. Typically, the platform provides APIs for generating UUID. The UUID, based on the standard calculations developed by the Open Software Foundation (OSF), uses Ethernet card addresses, nanosecond time, chip ID codes, and many possible numbers. A combination of the following parts: The current date and time (the first part of the UUID is related to time, and if you generate a UUID after a few seconds after generating a UUID, the first part is different, the rest is the same), the clock sequence, and the globally unique IEEE Machine identification number (if there is a NIC, obtained from the NIC, No NIC is available in any other way, the only drawback of the UUID is that the resulting string will be relatively long. The most common use of the standard for UUID is the Microsoft GUID (Globals Unique Identifiers).
In ColdFusion, you can use the Createuuid () function to easily generate a UUID in the form of: Xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx (8-4-4-16), where each x is 0-9 or a-f A hexadecimal number within the range. The standard UUID format is: xxxxxxxx-xxxx-xxxx-xxxxxx-xxxxxxxxxx (8-4-4-4-12)
code is as follows |
&nbs P; |
<?php Function guid () { I F (function_exists (' Com_create_guid ')) { return Com_create_ GUID (); }else{ Mt_srand (double) Microtime () *10000); //optional for PHP 4.2.0 and up. $charid = Strtoupper (MD5 ( Uniqid (rand (), true)) $hyphen = Chr (); //"-" &NBSP; & nbsp; $uuid = chr (123) //"{" &NBSP; substr ($charid, 0, 8). $hyphen . substr ($charid, 8, 4). $hyphen substr ($charid, 4). $hyphen substr ($charid, 4). $hyphen substr ($charid, 20,12) chr (125); //"}" &NBSP; return $uuid; } } |