php生成唯一的串

1.方法一:

<?php
    md5(uniqid('aa',true));
?>

2.方法2:

//生成16位的串
$randLength=6; $chars='abcdefghijklmnopqrstuvwxyz'; $len=strlen($chars); $randStr=''; for ($i=0;$i<$randLength;$i++){ $randStr.=$chars[rand(0,$len-1)]; } $tokenvalue=$randStr.time();

3.方法3:

$str = str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890');
$str = $str.uniqid();
return md5($str);