Home  >  Article  >  php教程  >  随机生成含大小写字母、数字的字符串

随机生成含大小写字母、数字的字符串

WBOY
WBOYOriginal
2016-06-07 11:34:381580browse

随机生成含有大小写字母,数字的字符串。可以修改定制。
$str = null;<br> $num = 10;// 字符串长度<br> $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";//如果不需要小写字母,可以把小写字母都删除<br> $max = strlen($strPol)-1;<br> <br> for($i=0;$i     $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数<br> }<br> echo $str;

AD:真正免费,域名+虚机+企业邮箱=0元

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