wp_generate_uuid4

Generate a random UUID (version 4).

Description

(string) wp_generate_uuid4(); 

Returns (string)

UUID.


Usage

  1. if ( !function_exists( 'wp_generate_uuid4' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_generate_uuid4(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_generate_uuid4() { 
  2. return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',  
  3. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),  
  4. mt_rand( 0, 0xffff ),  
  5. mt_rand( 0, 0x0fff ) | 0x4000,  
  6. mt_rand( 0, 0x3fff ) | 0x8000,  
  7. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) 
  8. );