Home  >  Article  >  Backend Development  >  PHP 一个随机字符串生成代码_php技巧

PHP 一个随机字符串生成代码_php技巧

WBOY
WBOYOriginal
2016-05-17 09:25:121016browse
复制代码 代码如下:

/*************
*@l - length of random string
*/
function generate_rand($l){
$c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
for($i=0; $i$rand.= $c[rand()%strlen($c)];
}
return $rand;
}

这里是摘自脚本之家之前发布的文章。更多的技巧可以参考。
收集的二十一个实用便利的PHP函数代码
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