常用代码整理篇一
时间:2009-05-06 来源:hkebao
1. <?php
//获取域名或主机地址
echo $_SERVER['HTTP_HOST']."<br>";
//获取网页地址
echo $_SERVER['PHP_SELF']."<br>";
//获取网址参数
echo $_SERVER["QUERY_STRING"]."<br>";
//来源网页的详细地址
echo $_SERVER['HTTP_REFERER']."<br>";
?>
2.生成随机数
function random($length) {
$hash = "@#@#";
$chars = "@#ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz@#";
$max = strlen($chars) - 1;
mt_srand((double)microtime()*100000000);
for($i=0;$i<$length;$i++) {
$hash.=$chars[mt_rand(0,$max)];
}
return $hash;
}
echo random(10)."<br>";
//获取域名或主机地址
echo $_SERVER['HTTP_HOST']."<br>";
//获取网页地址
echo $_SERVER['PHP_SELF']."<br>";
//获取网址参数
echo $_SERVER["QUERY_STRING"]."<br>";
//来源网页的详细地址
echo $_SERVER['HTTP_REFERER']."<br>";
?>
2.生成随机数
function random($length) {
$hash = "@#@#";
$chars = "@#ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz@#";
$max = strlen($chars) - 1;
mt_srand((double)microtime()*100000000);
for($i=0;$i<$length;$i++) {
$hash.=$chars[mt_rand(0,$max)];
}
return $hash;
}
echo random(10)."<br>";
相关阅读 更多 +