我已经多次尝试独立使用它,但我没有得到非法字符的 ID。好吧,但是当下面的代码在我的网站上运行时,它会生成非法字符,例如:XY�DV3VD、L6XÝOMJ3
输出必须由 [AZ] 和 [0-9] 组成。这怎么可能?感谢您的想法。
function uniqeeID($len){
//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1));
//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));
//Removing any . or / and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
//finally I take the first $len characters from the $rnd_id
$rnd_id = strtoupper(substr($rnd_id,0,$len));
return $rnd_id;
}