《php经典实例》的摘抄记录
function str_rand($length = 32, $characters = '0987654321qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP')
{
if(!is_int($length) || $length < 0){
return false;
}
$characters_length = strlen($characters) - 1;
$string = '';
for($i = $length; $i > 0; $i--){
$string .= $characters[mt_rand(0, $characters_length)];
}
return $string;
}