Quantcast

Headers already sent error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Headers already sent error

kranthi117
Hi all,

I have the following code
public function indexAction ()
{
     $this->getResponse()->setHttpResponseCode(404);
}

It gives me an error saying "Uncaught exception
'Zend_Controller_Response_Exception' with message 'Cannot send
headers; headers already sent in , line 0' in
/usr/share/php/Zend/Controller/Response/Abstract.php on line 323"
Replacing that with

public function indexAction ()
{
    header('HTTP/1.1 404 Not Found');
}
works as expected. No error, 404 header is sent.

Moreover I could not understand why $ok = headers_sent($file, $line)
is returning $ok = true but empty file name and line number. (also the
zf library is not modified. I re installed and verified)

Please help me.

Kranthi.
http://goo.gl/e6t3

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Headers already sent error

kranthi117
Hi all,

Looks like I was able to figure out the problem.
http://php.net/flush in the layout.

Still I could not understand out why $ok = headers_sent($file, $line)
is returning $ok=true but $file and $line are empty.

Kranthi.
http://goo.gl/e6t3

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Loading...