codecamp

parse_header()

作用:将原生的头部信息解析为关联数组。 语法: array parse_header(string $header_str) 参数:

  • $header_str 头部信息字符串。

返回值:

  • 解析结果。

示例:

<?php
$header = 'HTTP/1.1 200 OK
Date: Wed, 28 Sep 2016 04:46:33 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
X-Powered-By: PHP/5.4.16
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8';
print_r(parse_header($header));
/** 将输出如下
Array
(
    [0] => HTTP/1.1 200 OK
    [Date] => Wed, 28 Sep 2016 04:46:33 GMT
    [Server] => Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
    [X-Powered-By] => PHP/5.4.16
    [Expires] => Thu, 19 Nov 1981 08:52:00 GMT
    [Cache-Control] => no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    [Pragma] => no-cache
    [Keep-Alive] => timeout=5, max=100
    [Connection] => Keep-Alive
    [Transfer-Encoding] => chunked
    [Content-Type] => text/html; charset=UTF-8
)
*/
session_retrieve()
camelcase2underline()
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

挂钩机制

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }