PHP产生随机字符串函数
PHP产生随机字符串函数
发布时间:2016-12-29 来源:查字典编辑
摘要:

<?php

/**

*产生随机字符串

*

*产生一个指定长度的随机字符串,并返回给用户

*

*@accesspublic

*@paramint$len产生字符串的位数

*@returnstring

*/

functionrandStr($len=6){

$chars='ABDEFGHJKLMNPQRSTVWXYabdefghijkmnpqrstvwxy23456789#%*';//characterstobuildthepasswordfrom

mt_srand((double)microtime()*1000000*getmypid());//seedtherandomnumbergenerater(mustbedone)

$password='';

while(strlen($password)<$len)

$password.=substr($chars,(mt_rand()%strlen($chars)),1);

return$password;

}

?>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类