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

生成随机字符串,包含大写、小写字母、数字php代码

WBOY
WBOYOriginal
2016-06-08 17:25:491105browse
<script>ec(2);</script>
function randstr($length) {
 $hash = '';
 $chars = 'abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz';
 $max = strlen($chars) - 1;
 mt_srand((double)microtime() * 1000000);
 for($i = 0; $i   $hash .= $chars[mt_rand(0, $max)];
 }
 return $hash;
}
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