Last active
December 4, 2020 17:09
-
-
Save rahenrique/59bfd1f0ed00ea9fa0efe6a0bb824dde to your computer and use it in GitHub Desktop.
GUID em PHP útil para criação de identificadores únicos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getGUID(){ | |
mt_srand((double)microtime()*10000); | |
$charid = strtolower(md5(uniqid(rand(), true))); | |
$hyphen = chr(45); | |
$uuid = substr($charid, 0, 8).$hyphen | |
.substr($charid, 8, 4).$hyphen | |
.substr($charid,12, 4).$hyphen | |
.substr($charid,16, 4).$hyphen | |
.substr($charid,20,12); | |
return $uuid; | |
} | |
echo getGUID(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment