You are here

function uuid_generate in Universally Unique IDentifier 7

Generates an universally unique identifier.

This function first checks for the PECL alternative for generating universally unique identifiers. If that doesn't exist, then it falls back on PHP for generating that.

Return value

string An UUID, made up of 32 hex digits and 4 hyphens.

3 calls to uuid_generate()
UUIDAPITestCase::testApiFunctions in ./uuid.test
Tests uuid function calls.
UUIDNodeTestCase::testNodeCrud in ./uuid.test
Tests CRUD on nodes with UUID functions.
uuid_entity_presave in ./uuid.entity.inc
Implements hook_entity_presave().
1 string reference to 'uuid_generate'
UUIDAPITestCase::testApiFunctions in ./uuid.test
Tests uuid function calls.

File

./uuid.inc, line 23
Handling of universally unique identifiers.

Code

function uuid_generate() {
  $callback = drupal_static(__FUNCTION__);
  if (empty($callback)) {
    if (function_exists('uuid_create') && !function_exists('uuid_make')) {
      $callback = '_uuid_generate_pecl';
    }
    elseif (function_exists('com_create_guid')) {
      $callback = '_uuid_generate_com';
    }
    else {
      $callback = '_uuid_generate_php';
    }
  }
  return $callback();
}