Overview

Packages

  • awl
    • AuthPlugin
    • AwlDatabase
    • Browser
    • classEditor
    • DataEntry
    • DataUpdate
    • EMail
    • iCalendar
    • MenuSet
    • PgQuery
    • Session
    • Translation
    • User
    • Utilities
    • Validation
    • vCalendar
    • vComponent
    • XMLDocument
    • XMLElement
  • None

Functions

  • awl_version
  • check_by_regex
  • dbg_error_log
  • dbg_log_array
  • define_byte_mappings
  • deprecated
  • fatal
  • force_utf8
  • get_fields
  • gzdecode
  • olson_from_tzstring
  • param_to_global
  • quoted_printable_encode
  • replace_uri_params
  • session_salted_md5
  • session_salted_sha1
  • session_simple_md5
  • session_validate_password
  • trace_bug
  • uuid
  • Overview
  • Package
  • Function

Function uuid

Generates a Universally Unique IDentifier, version 4.

RFC 4122 (http://www.ietf.org/rfc/rfc4122.txt) defines a special type of Globally Unique IDentifiers (GUID), as well as several methods for producing them. One such method, described in section 4.4, is based on truly random or pseudo-random number generators, and is therefore implementable in a language like PHP.

We choose to produce pseudo-random numbers with the Mersenne Twister, and to always limit single generated numbers to 16 bits (ie. the decimal value 65535). That is because, even on 32-bit systems, PHP's RAND_MAX will often be the maximum signed value, with only the equivalent of 31 significant bits. Producing two 16-bit random numbers to make up a 32-bit one is less efficient, but guarantees that all 32 bits are random.

The algorithm for version 4 UUIDs (ie. those based on random number generators) states that all 128 bits separated into the various fields (32 bits, 16 bits, 16 bits, 8 bits and 8 bits, 48 bits) should be random, except : (a) the version number should be the last 4 bits in the 3rd field, and (b) bits 6 and 7 of the 4th field should be 01. We try to conform to that definition as efficiently as possible, generating smaller values where possible, and minimizing the number of base conversions.

Package: awl\Utilities
Copyright:

Copyright (c) CFD Labs, 2006. This function may be used freely for any purpose ; it is distributed without any form of warranty whatsoever.


License: GNU LGPL version 3 or later
Author: David Holmes dholmes@cfdsoftware.net
Located at AWLUtilities.php
Return value summary
string A UUID, made up of 32 hex digits and 4 hyphens.
API documentation generated by ApiGen