Home  >  Article  >  Backend Development  >  php 随机生成10位字符代码_PHP

php 随机生成10位字符代码_PHP

WBOY
WBOYOriginal
2016-06-01 12:23:481128browse
复制代码 代码如下:
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)."
";


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn