zoukankan      html  css  js  c++  java
  • file_get_contents获取状态码

    <?php

    //加上@ 是为了防止file_get_contents获取失败返回至命错误,影响后面的程序运行

    @file_get_contents("http://tqybw.net");
    var_dump($http_response_header);
    //$http_response_header 数组与 get_headers() 函数类似。当使用HTTP 包装器时,$http_response_header 将会被 HTTP 响应头信息填充。
    //$http_response_header 将被创建于局部作用域中。

    ?>

    //输出结果

    array(16) {
      [0]=>
      string(15) "HTTP/1.0 200 OK"
      [1]=>
      string(20) "Accept-Ranges: bytes"
      [2]=>
      string(23) "Cache-Control: no-cache"
      [3]=>
      string(21) "Content-Length: 14722"
      [4]=>
      string(23) "Content-Type: text/html"
      [5]=>
      string(35) "Date: Wed, 28 Nov 2018 06:11:27 GMT"
      [6]=>
      string(21) "Etag: "5bf3770c-3982""
      [7]=>
      string(44) "Last-Modified: Tue, 20 Nov 2018 02:53:00 GMT"
      [8]=>
      string(39) "P3p: CP=" OTI DSP COR IVA OUR IND COM ""
      [9]=>
      string(16) "Pragma: no-cache"
      [10]=>
      string(15) "Server: BWS/1.1"
      [11]=>
      string(141) "Set-Cookie: BAIDUID=9F2F8D69F1017368E0269BCAE89CF63A:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com"
      [12]=>
      string(137) "Set-Cookie: BIDUPSID=9F2F8D69F1017368E0269BCAE89CF63A; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com"
      [13]=>
      string(111) "Set-Cookie: PSTM=1543385487; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com"
      [14]=>
      string(21) "Vary: Accept-Encoding"
      [15]=>
      string(33) "X-Ua-Compatible: IE=Edge,chrome=1"
    }


  • 相关阅读:
    Centos7 关闭防火墙
    Linux下磁盘挂载
    Sqlserver游标复习
    Redis-benchmark测试Redis性能
    将treeview控件内容导出图片
    使用redis进行消息推送
    web性能优化系列之网站瓶颈识别
    SqlServer时间格式化
    PHP二位数组/多维数组 根据某个键值排序
    VIM Taglist + ctags
  • 原文地址:https://www.cnblogs.com/yaradish/p/10031838.html
Copyright © 2011-2022 走看看