kakatoji

GUID generator

Jul 19th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. // http://guid.us/GUID/PHP
  2. function getGUID(){
  3. if (function_exists('com_create_guid')){
  4. return com_create_guid();
  5. }else{
  6. mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
  7. $charid = strtoupper(md5(uniqid(rand(), true)));
  8. $hyphen = chr(45);// "-"
  9. $uuid = chr(123)// "{"
  10. .substr($charid, 0, 8).$hyphen
  11. .substr($charid, 8, 4).$hyphen
  12. .substr($charid,12, 4).$hyphen
  13. .substr($charid,16, 4).$hyphen
  14. .substr($charid,20,12)
  15. .chr(125);// "}"
  16. return $uuid;
  17. }
  18. }
Add Comment
Please, Sign In to add comment