how to jump to other page after header had been sent ?
I have some codes writed in my template file, I want to using php to jump to other page when some condition is true, but I can not use header command here ,for the header info had been sent in other php file before this template file. then how can I jump to other url now ? only the way to use js?
Warning: Cannot modify header information - headers already sent by ...
Answer
Use output buffering and header clearing to achieve this.
ob_start()
...
if (!headers_sent()) {
foreach (headers_list() as $header)
header_remove($header);
}
ob_flush_end()
Untested, but give it a shot.
No comments:
Post a Comment