欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP 创建GUID唯一标识

程序员文章站 2022-11-22 10:32:06
function createGuid() { mt_srand((double)microtime()*10000); $charid = strtoupper(md5(uniqid(mt_srand(), true))); $hyphen = chr(45); $uuid = substr($c ......
function createguid()
{
    mt_srand((double)microtime()*10000);
    $charid = strtoupper(md5(uniqid(mt_srand(), 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