B
B
banny_name2015-10-03 13:10:58
PHP
banny_name, 2015-10-03 13:10:58

Why doesn't sending headers work?

In the application class, I call the controller
following response->send () - sending headers.
send():

public function send(){
    
    $status = isset($this->http_messages[$this->http_status])? $this->http_messages[$this->http_status] : $this->http_status;
    
    if(!headers_sent()){
      if(isset($_SERVER['SERVER_PROTOCOL'])){
        header($_SERVER['SERVER_PROTOCOL']. ' ' .$status, true);
      }
      else{
        header('HTTP/1.1 '.$status, true);
      }
    }
  }

Status is always 200
I set cookies or do a redirect, then I do response->send, that is,
in the application class it looks like this:
App::start(){
$controller->action() - тут отправляются заголовки( установка кук и т.д)
$response->send();
}

if you remove response->send(), then everything works fine, why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2015-10-03
@Stalker_RED

You have if(!headers_sent()) there ...
Apparently, some headers are sent earlier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question