当前位置:Gxlcms > PHP教程 > php生成uuid与php图片上传微秒命名文件名

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

时间:2021-07-01 10:21:17 帮助过:15人阅读

  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. }

人气教程排行