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
上一篇: 编写可读代码:通过提前返回来减少缩进