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 来源: https://www.cnblogs.com/52lnamp/p/12517293.html