How to Solve “Headers already sent” error in PHP

This Warning is shown by PHP when you use the header function to output headers or use the setcookie function to set cookies after any echo or content which is not inside PHP tag.We need to make sure functions that send or modify HTTP headers must be invoked before any output is made.

You can also check other tutorial of PHP headers,

Solution

you can use output buffering functions to buffer your output automatically before sent any output and the output is sent as a chunk at the end.