清除以前设置的标题php [英] Clear previously set headers php

查看:102
本文介绍了清除以前设置的标题php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以清除存储在header_list()中的当前信息

I would like to know if its possible to clear the current information stored in header_list()

if(headers_sent()){
    foreach(headers_list() as $header){
        header_remove($header);
    }
}
var_dump(headers_list());


推荐答案

headers_sent 表示删除标题为时已晚。他们已经已发送。因此函数的名称。

headers_sent indicates that it is too late to remove headers. They're already sent. Hence the name of the function.

你想要的是专门检查标题是否已经发送了 。然后你知道修改它们是安全的。

What you want is to specifically check if the headers have not been sent yet. Then you know it's safe to modify them.

if (!headers_sent()) {
  foreach (headers_list() as $header)
    header_remove($header);
}

这篇关于清除以前设置的标题php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆