<html>
<head>
       <title>随机产生密码!</title>
</head>
<body>
 <?php
 function randompassword($slength=6){
 $sall=explode(" ",
 "a b c d e f g h i j k l m n o p q r s t u v w x y z".
 " A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".
 " 0 1 2 3 4 5 6 7 8 9");
 for($si=0; $si<$slength;$si++)
 mt_srand((double)microtime()*1000000);
 $srandy=mt_rand(0,61);
 $spass=$sall[$srandy];
 return $spass;
 }
 echo randompassword(8);
 ?>
 
</body>
</html>
是不是这样子的?

解决方案 »

  1.   

    <html>
    <head>
           <title>随机产生密码!</title>
    </head>
    <body>
     <?php
     function randompassword($slength=6){
       $sall=explode(" ",
           "a b c d e f g h i j k l m n o p q r s t u v w x y z".
           " A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".
           " 0 1 2 3 4 5 6 7 8 9");
     for($si=0; $si<$slength;$si++)
     mt_srand((double)microtime()*1000000);
     $srandy=(string)mt_rand();
     $spass="";
     for($i="0";$i<$slength;$i++){
         $spass.=$sall[$srandy[$i]];
     }
     return $spass;
     }
     echo randompassword(8);
     ?>
     
    </body>
    </html>