parse_header()

2018-06-22 13:59 更新

作用:將原生的頭部信息解析為關(guān)聯(lián)數(shù)組。 語(yǔ)法: array parse_header(string $header_str) 參數(shù):

  • $header_str 頭部信息字符串。

返回值:

  • 解析結(jié)果。

示例:

  1. <?php
  2. $header = 'HTTP/1.1 200 OK
  3. Date: Wed, 28 Sep 2016 04:46:33 GMT
  4. Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
  5. X-Powered-By: PHP/5.4.16
  6. Expires: Thu, 19 Nov 1981 08:52:00 GMT
  7. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  8. Pragma: no-cache
  9. Keep-Alive: timeout=5, max=100
  10. Connection: Keep-Alive
  11. Transfer-Encoding: chunked
  12. Content-Type: text/html; charset=UTF-8';
  13. print_r(parse_header($header));
  14. /** 將輸出如下
  15. Array
  16. (
  17. [0] => HTTP/1.1 200 OK
  18. [Date] => Wed, 28 Sep 2016 04:46:33 GMT
  19. [Server] => Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
  20. [X-Powered-By] => PHP/5.4.16
  21. [Expires] => Thu, 19 Nov 1981 08:52:00 GMT
  22. [Cache-Control] => no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  23. [Pragma] => no-cache
  24. [Keep-Alive] => timeout=5, max=100
  25. [Connection] => Keep-Alive
  26. [Transfer-Encoding] => chunked
  27. [Content-Type] => text/html; charset=UTF-8
  28. )
  29. */
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)