随便想到一种方法,写了出来,呵呵,不一定好用。
function randName()
{
$str = md5(mt_rand());
$str = str_replace(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), "", $str);
$str = strtoupper($str);
$str = substr($str, 0, 6);

解决方案 »

  1.   

    //全是大写:
    $Length = rand(8, 16);
    //用户名的长度也随机,8位到16位吧
    for($i=0; $i<$Length; $i++)
    {
    $tmp = rand(65, 90);
    $username.= chr($tmp);
    }
    echo $username;
    //全是小写:
    echo strtolower($username);
      

  2.   

    <?php function randName($type = "strtoupper", $length = 6)
    {
    $str = md5(mt_rand());
    $str = str_replace(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), "", $str);
    $str = $type($str);
    $str = substr($str, 0, $length);
    return $str;
    }
    echo randName();

    ?>
      

  3.   

    function random($length) {
    $string = '';
    $char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $max = strlen($char) - 1;
    mt_srand((double)microtime() * 1000000);
    for($i = 0; $i < $length; $i++) {
    $string .= $char[mt_rand(0, $max)];
    }
    return $string;
    }$char = 'abcdefghijklmnopqrstuvwxyz';
    就是小写了
      

  4.   

    nod
    楼主,楼上各位的方法都不错...
    足以解决你的问题.