Home > Backend Development > PHP Tutorial > Example of php generating GUID (Globally Unique Identifier)_PHP Tutorial

Example of php generating GUID (Globally Unique Identifier)_PHP Tutorial

WBOY
Release: 2016-07-21 14:53:41
Original
1019 people have browsed it

GUID: Globally Unique Identifier (Globally Unique Identifier), also known as UUID (Universally Unique IDentifier). GUID is a 128-bit binary numeric identifier generated by a specific algorithm and used to indicate the uniqueness of a product. GUID is mainly used to assign unique identifiers in a network or system with multiple nodes and computers.

On the Windows platform, GUID is widely used in Microsoft products to identify objects such as registry keys, class and interface identifiers, databases, system directories, etc.

The format of the GUID is "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", where each x is a 32-digit hexadecimal number in the range of 0-9 or a-f. For example: 6F9619FF-8B86-D011-B42D-00C04FC964FF is a valid GUID value.

★GUID is unique in space and time, ensuring that different numbers generated in different places at the same time are different. ★No two computers in the world will generate duplicate GUID values. ★When a GUID is needed, it can be automatically generated completely by the algorithm and does not require an authoritative organization to manage it. ★GUID has a fixed length and is relatively short, which is very suitable for sorting, identification and storage.

Code:

Copy to ClipboardLiehuo.Net CodesQuoted content: [www.bkjia.com] function create_guid() {
$charid = strtoupper(md5(uniqid(mt_rand(), true)));
$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(125);// "}"
return $uuid;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364748.htmlTechArticleGUID: Globally Unique Identifier (Globally Unique Identifier), also known as UUID (Universally Unique IDentifier). GUID is a 128-bit binary number generated by a specific algorithm...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template