All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
PHP生成随机字符串_[PHP教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/17 7:38:08 Browse times: 442 Comment times: 0

PHP生成随机字符串_[PHP教程]


Head photo

Go homepage
Upload pictures
Write articles

PHP生成随机字符串_[PHP教程]

PHP生成随机字符串的函数,下面是我在网上找到的2个关于PHP随机字符串的函数,希望大家喜欢。

< ?php
function genRandomString(len)
{
chars = array(
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
"3", "4", "5", "6", "7", "8", "9"
);
charsLen = count(chars) - 1;

shuffle(chars); // 将数组打乱

output = "";
for (i=0; i {
output .= chars[mt_rand(0, charsLen)];
}

return output;

}

str = genRandomString(25);
str .= "
";
str .= genRandomString(25);
str .= "
";
str .= genRandomString(25);

echo str;

?>

/* Generate Password
* Length : 8
*/
str = "0123456789abcdefghijklmnopqrstuvwxyz"; // 输出字符集
n = 8; // 输出串长度
len = strlen(str)-1;
for(j=0 ; j<200 ; j++){
for(i=0 ; i s .= str[rand(0,len)];
}
echo s . "
";
s = "";
}

?>





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.