PHP 创建GUID唯一标识

function createGuid()
{
    mt_srand((double)microtime()*10000);
    $charid = strtoupper(md5(uniqid(rand(), true)));
    $hyphen = chr(45);
    $uuid = substr($charid, 0, 8) . $hyphen
        . substr($charid, 8, 4) . $hyphen
        . substr($charid,12, 4) . $hyphen
        . substr($charid,16, 4) . $hyphen
        . substr($charid,20,12);
    return $uuid;
}
echo createGuid(); // 8929E377-74F8-3DEC-4A86-2E5289A8327F

猜你喜欢

转载自www.cnblogs.com/52lnamp/p/12517293.html