首页  >  文章  >  后端开发  >  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