Sr. PHP Programmer Question:
Download Questions PDF

How does one prevent the following Warning 'Warning: Cannot modify header information - headers already sent' and why does it occur in the first place?


Do not output anything to the browser before using code that modifies the HTTP headers. Once you call echo or any other code that clears the buffer you can no longer set cookies or headers. That is also true for error messages, so if an error happens before you use the header command and the INI directive display_errors is set then that will also cause that error to show.

Download Senior PHP Programmer Interview Questions And Answers PDF

Previous QuestionNext Question
What are the __construct() and __destruct() methods in a PHP class?Explain how to execute a PHP script using command line?