Created
November 22, 2017 02:23
-
-
Save yusureabc/416e9e88ff35ac5d5dd68f56e2858d86 to your computer and use it in GitHub Desktop.
PHP生成uuid
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 uuid($prefix = '') | |
{ | |
$chars = md5(uniqid(mt_rand(), true)); | |
$uuid = substr($chars,0,8) . '-'; | |
$uuid .= substr($chars,8,4) . '-'; | |
$uuid .= substr($chars,12,4) . '-'; | |
$uuid .= substr($chars,16,4) . '-'; | |
$uuid .= substr($chars,20,12); | |
return $prefix . $uuid; | |
} | |
echo uuid(); | |
echo '<br/>'.session_create_id(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment