PHP简单生成随机字符串自定义方法

function get_randomstr($lenth = 6) {
    return get_random($lenth'123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
}
 
function get_random($length$chars '0123456789') {
    $hash '';
    $max strlen($chars) - 1;
    for($i = 0; $i $length$i++) {
        $hash .= $chars[mt_rand(0, $max)];
    }
    return $hash;
}
原文地址:https://www.cnblogs.com/8834760y/p/5428287.html