PHP 生成订单号,GUID 方法
生成订单号function build_order_no() { <br>
return date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);<br>
}
生成GUIDfunction guid() { <br>
if (function_exists('com_create_guid')) { <br>
return com_create_guid(); <br>
} else { <br>
mt_srand((double)microtime()*10000);<br>
$charid = strtoupper(md5(uniqid(rand(), true))); <br>
$hyphen = chr(45); <br>
$uuid = chr(123) <br>
.substr($charid, 0, 8).$hyphen <br>
.substr($charid, 8, 4).$hyphen <br>
.substr($charid,12, 4).$hyphen <br>
.substr($charid,16, 4).$hyphen <br>
.substr($charid,20,12) <br>
.chr(125);<br>
return $uuid; <br>
}<br>
}
更新技术分享,请移步 PHP工程师订阅号。
云栖大会北京站:阿里技术专家难得出镜,这次一下来了100多位?!