本文主要是介绍php生成唯一识别码uuid,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
标准的UUID格式为:xxxxxxxx-xxxx-xxxx-xxxxxx-xxxxxxxxxx(8-4-4-4-12)
function uuid()
{ $chars = md5(uniqid(mt_rand(), true)); $uuid = substr ( $chars, 0, 8 ) . '-'. substr ( $chars, 8, 4 ) . '-' . substr ( $chars, 12, 4 ) . '-'. substr ( $chars, 16, 4 ) . '-'. substr ( $chars, 20, 12 ); return $uuid ;
} echo uuid(); //Returns like 'dba5ce3e-430f-cf1f-8443-9b337cb5f7db'
这篇关于php生成唯一识别码uuid的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!