0

In one of my scripts, something failed and an error was outputted, When i tried to redirect using header('Location: back.php'), apparently the headers were already sent.

Now, how is that possible? I don't have a single HTML tag on that page, and I didn't modify the headers in any way.

I found only one thing that could explain this, PHP errors sometimes have HTML tags inside (bold, anchor, etc..) So can this be the cause of that "headers already sent error"? If so, how do i fix it?

Naing Lin Aung
  • 3,373
  • 4
  • 31
  • 48
Adrao
  • 412
  • 5
  • 18
  • sometimes it can be as simple as a space after a closing `?>` tag. – serakfalcon Aug 10 '14 at 15:17
  • by default errors many errors in php will output to the browser, which would cause the headers already sent thing, (well, actually it wouldn't because your code would stop before it even reaches there) but you should fix or handle the errors anyway – serakfalcon Aug 10 '14 at 15:19
  • you might try deleting the closing ?> tag, assuming you don't have anything after it such as HTML -- and if you do, that's the problem. – vch Aug 10 '14 at 15:19
  • possible duplicate of [How to fix "Headers already sent" error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Funk Forty Niner Aug 10 '14 at 15:21
  • @Fred-ii- Thanks, that answer apparently applies to my problem also. – Adrao Aug 10 '14 at 15:23

0 Answers0