欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-06-15 22:32:00
...
  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. }
复制代码