php生成隨機數 自定義函數 randstr($length)

function randstr($len=6){
    $chars='abcdefghijklmnopqrstuvwxyz0123456789';
    #characters to build the password from
    mt_srand((double)microtime()*1000000*getmypid());
    #seed the random number generater (must be done)
    $password='';
    while(strlen($password)<$len)
        $password.=substr($chars,(mt_rand()%strlen($chars)),1);
    return $password;
}

$salt = randstr();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章