测试用缓存中的标记头,替换页面中的标记头
<?php
class test
{
public $headers=array();
public function set_header($header,$replace=true)
{
if( strncasecmp($header,'content-length',14)===0)
{
return $this;
}
$this->headers[]=array($header,$replace);
return $this->headers;
}
public function getheader()
{
return $this->headers;
}
}
$test=new test();
//这里的$str就是缓存中被序列化的header标记头
//$head[0]="Content-Type:text/html; charset=utf8"
//$head[1]=1
$str='a:2:{s:6:"expire";i:1675868933;s:7:"headers";a:1:{i:0;a:2:{i:0;s:36:"Content-Type:text/html; charset=utf8";i:1;b:1;}}}ENDTS--->';
if(!preg_match('/^(.*)ENDTS--->/',$str,$match))
{
return false;
}
$cache_info=unserialize($match[1]);
foreach($cache_info['headers'] as $head)
{
$test->set_header($head[0],$head[1]);
}