Home > Article > Backend Development > PHP generates uuid format string example program_PHP tutorial
I think many friends don’t know what format uuid is a string, but if you have already come here, you will probably know what uuid is. Let’s take a look at how to generate a uuid string.
UUID refers to a number generated on one machine, which is guaranteed to be unique to all machines in the same time and space. Usually the platform will provide an API to generate UUID. The UUID is calculated according to the standards set by the Open Software Foundation (OSF), using the Ethernet card address, nanosecond time, chip ID number and many possible numbers. It is a combination of the following parts: the current date and time (the first part of the UUID is related to the time, if you generate a UUID after a few seconds, the first part is different and the rest are the same), clock Sequence, a globally unique IEEE machine identification number (if there is a network card, it is obtained from the network card, if there is no network card, it is obtained in other ways). The only flaw of UUID is that the generated result string will be relatively long. The most commonly used UUID standard is Microsoft's GUID (Globals Unique Identifiers).
In ColdFusion, you can use the CreateUUID() function to easily generate a UUID. The format is: xxxxxxxx-xxxx-xxxx- xxxxxxxxxxxxxxxx(8-4-4-16), where each x is one in the range of 0-9 or a-f. Hexadecimal number. The standard UUID format is: xxxxxxxx-xxxx-xxxx-xxxxxx-xxxxxxxxxx (8-4-4-4-12)
The code is as follows
|
Copy code | ||||
If (function_exists('com_create_guid')){
.substr($charid,20,12) .chr(125);