Clear previously set headers php

前端 未结 4 913
忘掉有多难
忘掉有多难 2021-02-05 16:15

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){
                


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 16:52

    To remove them all it's pretty simple:

    if ( ! headers_sent() ) {
        header_remove();
    }
    

    No looping required. If you don't pass a parameter to header_remove, it removes all headers set by PHP.

提交回复
热议问题