生成sessionid和随机密码的例子
更新时间:2006年10月09日 00:00:00 作者:
用这个可以来验证用户和生成随机密码--teaman
//----------------------------------------------------
// Function GetSID()
//
// Parameters : $nSize number of caracters, default 24
// Return value : 24 caracters string
//
// Description : This function returns a random string
// of 24 caracters that can be used to identify users
// on your web site in a more secure way. You can also
// use this function to generate passwords.
//----------------------------------------------------
function GetSID ($nSize=24) {
// Randomize
mt_srand ((double) microtime() * 1000000);
for ($i=1; $i<=$nSize; $i++) {
// if you wish to add numbers in your string,
// uncomment the two lines that are commented
// in the if statement
$nRandom = mt_rand(1,30);
if ($nRandom <= 10) {
// Uppercase letters
$sessionID .= chr(mt_rand(65,90));
// } elseif ($nRandom <= 20) {
// $sessionID .= mt_rand(0,9);
} else {
// Lowercase letters
$sessionID .= chr(mt_rand(97,122));
}
}
return $sessionID;
}
// Test the function
echo GetSID(16);
?>
相关文章
在PHP中利用XML技术构造远程服务(下)...2006-10-10
只要一个变量,需要在多个方法使用,就将这个变量声明为成员属性,可以直接在这个对象中的所有方法中使用 成员属性,相当于这个对象中的全局变量2011-06-06
就是把对象的成员(属性,方法)结合成一个独立的相同单位,并尽可能隐藏对象的内部细节2011-06-06
其实如果只是为了测试php的运行而不是服务器运行,可以用phpnow等,脚本之家都有提供下载。2010-07-07
Extended CHM PHP 语法手册之 DIY...2006-10-10
今天又一次遇到PHP 的一个提醒:Notice: Trying to get property of non-object problem,这种错误很常见2012-03-03
怎样在UNIX系统下安装php3...2006-10-10
使用php4加速网络传输...2006-10-10
Get或Post提交值的非法数据处理...2006-10-10
今天小编就为大家分享一篇关于PHP PDOStatement::execute讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧2019-01-01
最新评论