产生类似GUID的唯一ID
代码
function puid($seperator='')
{
//产生类似GUID的唯一ID,名为Php Unique ID或Personal Unique ID,简称PUID
$mstime = str_replace( ' ', '@', microtime() );
$address= ''; //$_SERVER['SERVER_NAME'].'('.$_SERVER['SCRIPT_NAME'].')<<'.$_SERVER['REMOTE_ADDR'].'#'.$_SERVER['HTTP_USER_AGENT'];
$rnd = mt_rand(10000,99999).'-'.mt_rand(10000,99999).'-'.mt_rand(10000,99999).'-'.mt_rand(10000,99999).'-'.mt_rand(10000,99999);
$pre_hash = $mstime.$address.$rnd;
$aft_hash = strtoupper(md5($pre_hash));
return $seperator?substr($aft_hash,0,8).$seperator.substr($aft_hash,8,4).$seperator.substr($aft_hash,12,4).$seperator.substr($aft_hash,16,4).$seperator.substr($aft_hash,20):$aft_hash;
}
{
//产生类似GUID的唯一ID,名为Php Unique ID或Personal Unique ID,简称PUID
$mstime = str_replace( ' ', '@', microtime() );
$address= ''; //$_SERVER['SERVER_NAME'].'('.$_SERVER['SCRIPT_NAME'].')<<'.$_SERVER['REMOTE_ADDR'].'#'.$_SERVER['HTTP_USER_AGENT'];
$rnd = mt_rand(10000,99999).'-'.mt_rand(10000,99999).'-'.mt_rand(10000,99999).'-'.mt_rand(10000,99999).'-'.mt_rand(10000,99999);
$pre_hash = $mstime.$address.$rnd;
$aft_hash = strtoupper(md5($pre_hash));
return $seperator?substr($aft_hash,0,8).$seperator.substr($aft_hash,8,4).$seperator.substr($aft_hash,12,4).$seperator.substr($aft_hash,16,4).$seperator.substr($aft_hash,20):$aft_hash;
}