PHP——生成唯一序列号UUID

前言

生成唯一的UUID

内容

<?php

function uuid($uid = '')
{
  $chars = md5(uniqid(mt_rand(), true));
  $uuid = substr($chars, 0, 8).'-';
  $uuid .= substr($chars, 8, 4).'-';
  $uuid .= substr($chars, 12, 4).'-';
  $uuid .= substr($chars, 16, 4).'-';
  $uuid .= substr($chars, 20, 12);
  return $uid . $uuid;
}
posted @ 2019-01-09 14:49  。思索  阅读(1390)  评论(0)    收藏  举报