This question already has an answer here:
This is not new topic, as everyone developer face problem usually redirecting to a link with this error
"Warning: Cannot modify header information "
i read different solutions for this problem using ob_start, but i was unable to understand the process. can somebody please explain with necessary detail and help me to understand why we face this problem and how it can be resolved. i am developing wordpress plugin and i am facing this problem in redirecting.
Regards
</div>
By calling ob_start()
, you are telling PHP to start output buffering. This basically means, when you try output stuff using commands like echo
etc. PHP will temporarily save/buffer this output. Header must be sent before the output, so since you're not actually sending the output to the browser, you can still modify the headers even after you have used commands such as echo
. When you are ready to send your output back to the user's browser you can use something like ob_end_flush
.