Share The uuid udf generation in PHP. phpuuid UDF _ PHP Tutorial

Source: Internet
Author: User
Tags 04x
Generate uuid udf sharing in PHP and phpuuid UDF. Share The UUID generation UDFs in PHP. The full name of the phpuuid UDFs UUID is Universallyuniqueidentifier. it is an identifier that can be generated by any computer, you do not need to generate UUID UDFs in PHP to share, phpuuid UDFs

UUID is the full name of Universally unique identifier. it is an identifier that can be generated by any computer and can be hardly duplicated without a central database for management. The value range of UUID is large. it is said that a UUID is allocated to every grain of sand in the world, and there will be no repetition.

UUID is required for WordPress code modification recently. However, PHP does not generate a UUID function, so you have to write one by yourself.

if (!function_exists('com_create_guid')) { function com_create_guid() {  return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',    mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),    mt_rand( 0, 0xffff ),    mt_rand( 0, 0x0fff ) | 0x4000,    mt_rand( 0, 0x3fff ) | 0x8000,    mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )  ); }}

The above code generates a UUID version 4. UUID currently has five versions. The fourth version is completely random and is easy to generate. Among them, com_create_guid is a function of PHP in Windows. it directly calls the CreateGuid function of COM to generate UUID, but there is no corresponding function library in Linux, so you have to write it yourself. To facilitate use on different platforms, a function with the same name is created. Other codes generate random numbers.

For usage, you can directly call com_create_guid.

UUID is the full name of Universally unique identifier. it is an identifier that can be generated on any computer without any need...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.