php 生成32位随机字符串 用于支付验证 用户注册

 //32位随机字符串
    function randstrpay($length=32) {
        $rand='';
        $randstr= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        $max = strlen($randstr)-1;
        mt_srand((double)microtime()*1000000);
        for($i=0;$i<$length;$i++) {
            $rand.=$randstr[mt_rand(0,$max)];
        }
        return $rand;
    }