PHP Build uuid,php Build uuid_php Tutorial

Source: Internet
Author: User

Generate uuid,php generated UUID in PHP


First, what is the UUID

The UUID is simply a string of globally unique (16 binary) numbers.

The full spell of the UUID is "universally unique Identifier", which can be translated as "Universal Unique identification code". The UUID is defined by the Open Source Software Foundation (Open Software Foundation, OSF) and is an integral part of the Distributed computing Environment (distributed Computing Environment, DCE).

The standard format for the UUID is "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx", with five sections of 8 characters, 4 characters, 4 characters, 4 characters, 12 characters, and a "-" interval between the two. The common GUID (globally Unique Identifier) is a Microsoft implementation of the UUID standard.

Second, why to use UUID

Benefits that call a lot AH ~ ~ ~, you casually Baidu put.

Third, the generation code of the UUID

This ..., really out of date, with the extension bar, do not write your own code.

Iv. installation of UUID extensions

Related extensions are here: PECL:: Package:: UUID.

The PHP extension installation steps are always the ones:

  

wget http://pecl.php.net/get/uuid-1.0.3.tgztar zxvf uuid-1.0. 3 . TGZCD UUID-1.0. 3 phpize. /Configuremake doinstall

OK, then edit the PHP configuration file, restart the server, to Phpinfo () to see the effect:

After the installation is successful, write two lines of code to test it:

  

 
 1 
   PHP2//uuid.php3echo uuid_create (), '
\ n '; 4 echo uuid_create (1); // Recommended Usage

Refresh the page several times to observe the changes of the two rows of uuid, what do you find? To learn more, learn how several versions of the UUID are defined.

V. Problems that may be encountered in installing the extension

Installing an extension encounters a problem that is usually caused by a system that lacks related components.

In CentOS 7, you need to install Libuuid-devel, which is available with the Yum command.

In Mac OS 10.9, you'll need to install LIBUUID, which is going to Libuuid | SourceForge.net download.

Well, that's all, there's a real V1 uuid available.


Linux has installed the PHP extension UUID but also reported call to undefined function uuid_make () This error


Is there already a MySQL
Otherwise
Php. INI configuration is problematic

How to create UUID in JS

Www.broofa.com/Tools/Math.uuid.js

Math.uuid = (function () {

Private array of chars to use

var CHARS = ' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '. Split (');

return function (len, radix) {

var chars = chars, uuid = [], rnd = math.random;

Radix = Radix | | Chars.length;

if (len) {

Compact form

for (var i = 0; i < len; i++) uuid[i] = chars[0 | rnd () *RADIX];

} else {

rfc4122, version 4 form

var R;

rfc4122 requires these characters

UUID[8] = uuid[13] = uuid[18] = uuid[23] = '-';

UUID[14] = ' 4 ';

Fill in random data. At i==19 set the high bits of clock sequence as

Per rfc4122, sec. 4.1.5

for (var i = 0; i < i++) {

if (!uuid[i]) {

R = 0 | Rnd () *16;

Uuid[i] = chars[(i = = 19)? (R & 0x3) | 0x8:r & 0XF];

}

}

}

Return Uuid.join (");

};

})();

Deprecated-only here for backward compatability

var randomuuid = Math.uuid;

function Generateuuid ()

{

return Math.uuid ();

}... Remaining full text >>

http://www.bkjia.com/PHPjc/891596.html www.bkjia.com true http://www.bkjia.com/PHPjc/891596.html techarticle generate uuid,php in PHP build uuid One, what is the UUID simple to say that the UUID is a string of the world's only (16 binary) digital string. UUID of the whole spell for universally Unique Identifier, can be translated into ...

  • Related Article

    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.