Home > php教程 > PHP源码 > body text

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

WBOY
Release: 2016-06-08 17:25:49
Original
1105 people have browsed it
<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;
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!