Jump to content
Larry Ullman's Book Forums

Cannot Modify Header Information Error


snapper
 Share

Recommended Posts

When a user clicks a button in my application, it is supposed to reroute them to a certain page in my application, but instead I get the following error message: 

 

Cannot modify header information - headers already sent by (output started at /home/colly/public_html/myapp/ItemsController.php:218)

 

and here is the function inside of the itemsController that generates the error:

public function actionRedirectSomewhere($itemId) {$this->redirect(array('items/index'));}

 

It still gives me the same error if I call the function without the parameter like this: 

actionRedirectSomewhere() {$this->redirect(array('items/index'));}

 

I am not aware of any headers that I am sending.

 

How can I fix this error?

Any help would be appreciated.

 

//snapper

Link to comment
Share on other sites

What is line 218 of ItemsController.php? It's not a matter of sending headers that's causing the problem exactly, it's that the browser has already received some data, such as HTML or even a blank space, which means the redirect cannot occur. 

Link to comment
Share on other sites

Here is line 218: public function actionRedirectSomewhere($itemId) {$this->redirect(array('items/index'));}

 

It's the function call with the redirect statement. You were right. I was getting this error because I omitted the closing php tag at the end of the ItemsController. I was told I should do that  (omitting closing php tags) but did not understand when, why and where I should omit this ?> if at all.

Link to comment
Share on other sites

 Share

×
×
  • Create New...