yzc164 发表于 2017-3-29 09:37:58

php 随机生成10位字符

  php 随机生成10位字符
  function randStr($len)
{
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; // characters to build the password from
$string='';
for(;$len>=1;$len--)
{
$position=rand()%strlen($chars);
$string.=substr($chars,$position,1);
}
return $string;
}
echo randStr(10)."<br>";
页: [1]
查看完整版本: php 随机生成10位字符