PHP

Its easy to make GUIDs in PHP. Below are modern, secure methods to generate RFC 4122 compliant UUIDs.

Method 1: Built-in Windows COM (Windows servers only)

$guid = com_create_guid();
echo $guid; // Example: {F47AC10B-58CC-4372-A567-0E02B2C3D479}

Method 2: Cryptographically Secure Cross-Platform (Recommended)

This method works on all platforms and uses cryptographically secure random number generation (PHP 7.0+):

function generateGUID() {
    // Generate 16 bytes of random data
    $data = random_bytes(16);
    
    // Set version to 0100 (UUID version 4)
    $data[6] = chr(ord($data[6]) & 0x0f | 0x40);
    
    // Set bits 6-7 to 10 (RFC 4122 variant)
    $data[8] = chr(ord($data[8]) & 0x3f | 0x80);
    
    // Format as UUID string
    return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}

$guid = generateGUID();
echo $guid; // Example: f47ac10b-58cc-4372-a567-0e02b2c3d479

Method 3: Simple Cross-Platform Helper Function

function getGUID() {
    // Try Windows COM first (if available)
    if (function_exists('com_create_guid')) {
        return trim(com_create_guid(), '{}');
    }
    
    // Otherwise use cryptographically secure random (PHP 7.0+)
    $data = random_bytes(16);
    $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // version 4
    $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // variant RFC4122
    
    return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}

// Usage:
$GUID = getGUID();
echo $GUID;

Note: The old implementation using md5(uniqid(rand())) is NOT cryptographically secure and should be avoided. Modern PHP (7.0+) provides random_bytes() which uses the system's CSPRNG (Cryptographically Secure Pseudo-Random Number Generator).

*Conforms to RFC 4122 UUID version 4 specification*