首頁  >  文章  >  後端開發  >  php生成uuid与php图片上传微秒命名文件名

php生成uuid与php图片上传微秒命名文件名

WBOY
WBOY原創
2016-07-25 08:52:161010瀏覽
  1. function guid(){
  2. if (function_exists('com_create_guid')){
  3. return com_create_guid();
  4. }else{
  5. mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
  6. $charid = strtoupper(md5(uniqid(rand(), true)));
  7. $hyphen = chr(45);// "-"
  8. $uuid = chr(123)// "{"
  9. .substr($charid, 0, 8).$hyphen
  10. .substr($charid, 8, 4).$hyphen
  11. .substr($charid,12, 4).$hyphen
  12. .substr($charid,16, 4).$hyphen
  13. .substr($charid,20,12)
  14. .chr(125);// "}"
  15. return $uuid;
  16. }
  17. }
复制代码


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn