這種方法生成的唯一標(biāo)識(shí)中沒有重復(fù)误澳。
<?php
public function createSn()
{
$units = array();
for($i=0;$i<1000000;$i++){
$units[]=md5(uniqid(md5(microtime(true)),true));
}
$count = count($units);
foreach ( $units as $uk => $uv)
{
$duplicates[$uv] = $uk;
}
echo count($duplicates);//1000000
}