php get请求添加headers,PHP get_headers()函数详解_PHP教程

get_headers:发送服务器响应HTTP请求

get_headers(字符串url[链接格式])

get_headers()以数组的形式返回服务器HTTP请求。如果执行失败,将返回FALSE和一个错误的水平E_WARNING》。

可选参数设置为1,get_headers()能分析系统的响应速度和集数组中的键。

注意:使用该函数需要把 php.ini里面的allow_url_fopen = On,才能使用。

实例如下:

打印结果:

Array

(

[0] => HTTP/1.1 200 OK

[1] => Connection: close

[2] => Date: Tue, 16 Nov 2010 09:48:20 GMT

[3] => Content-Length: 52708

[4] => Content-Type: text/html

[5] => Content-Location: http://www.ite5e.com/index.html

[6] => Last-Modified: Tue, 16 Nov 2010 09:19:13 GMT

[7] => Accept-Ranges: bytes

[8] => ETag: "50d16c556f85cb1:b1f76"

[9] => Server: Microsoft-IIS/6.0

[10] => X-Powered-By: ASP.NET

)

Array

(

[0] => HTTP/1.1 200 OK

[Connection] => close

[Date] => Tue, 16 Nov 2010 09:48:21 GMT

[Content-Length] => 52708

[Content-Type] => text/html

[Content-Location] => http://www.ite5e.com/index.html

[Last-Modified] => Tue, 16 Nov 2010 09:19:13 GMT

[Accept-Ranges] => bytes

[ETag] => "50d16c556f85cb1:b1f76"

[Server] => Microsoft-IIS/6.0

[X-Powered-By] => ASP.NET

)

http://www.bkjia.com/PHPjc/486068.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486068.htmlTechArticleget_headers:发送服务器响应HTTP请求 get_headers(字符串url[链接格式]) get_headers()以数组的形式返回服务器HTTP请求。如果执行失败,将返回FALSE和一...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值