Php generates a uuid format string instance program. Uuid is a string in what format I think many of my friends don't know, but you have come to estimate what uuid is. let's take a look at how to generate a uuid string. UUID refers to the uuid in what format. I don't think many of you know about it, but you have come to estimate what uuid is. let's take a look at how to generate a uuid string.
UUID refers to the number generated on a machine, which ensures that all machines in the same time and space are unique. Generally, the platform provides APIs for UUID generation. UUID is calculated according to the standards set by the Open Software Foundation (OSF), and uses Ethernet card addresses, nanoseconds, chip ID codes, and many possible numbers. The combination of the following parts: the current date and time (the first part of UUID is related to the time. if you generate a UUID in seconds, the first part is different and the rest are the same), the clock sequence, and the globally unique IEEE machine identification number (if there is a Nic, it is obtained from the NIC, and no Nic is obtained in other ways ), the unique defect of UUID is that the generated result string is long. The most common UUID standard is Microsoft's GUID (Globals Unique Identifiers ).
In ColdFusion, you can use the CreateUUID () function to generate a UUID in the format of xxxxxxxx-xxxx-xxxxxxxxxxxxxxxx (8-4-4-16 ), each x is a hexadecimal number in the range of 0-9 or a-f. The standard UUID format is: xxxxxxxx-xxxx-xxxxxx-XXXXXXXXXXXX (8-4-4-4-12)
The code is as follows: |
|
Function guid (){ If (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 (45 ); //"-" $ Uuid = chr (1, 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 (1, 125 ); //"}" Return $ uuid; } } ?> |
Bytes. UUID refers...