1:MD5加密(有一定概率出现重复)(例:2995cdd038beb76145b675a7cef2b994)
md5(time().mt_rand(1,1000000))
2:uniqid()函数(由于基于系统时间,通过该函数生成的 ID 不是最佳的。如需生成绝对唯一的 ID,请使用 md5() 函数配合使用)(例:6083a5d06c64d)
3:session_create_id()函数(PHP 7.1新增函数)重复率较低,一般情况下可使用(例:j8emn2fn64dgk847o7m0b42ndp)
4:自定义方法(例:10FD7F36-A8CC-36CC-38A6-A9286C969812)
public function create_guid() {
$id = 1;
$uid = uniqid();
$data = 'test';
$data .= $_SERVER['REQUEST_TIME'];
$data .= $_SERVER['HTTP_USER_AGENT'];
$data .= $_SERVER['REMOTE_ADDR'];
$data .= $_SERVER['REMOTE_PORT'];
$hash = strtoupper(hash('ripemd128', $uid . $id . md5($data)));
return substr($hash, 0, 8) . '-' . substr($hash, 8, 4) . '-' . substr($hash, 12, 4) . '-' . substr($hash, 16, 4) . '-' . substr($hash, 20, 12);
}