Http headers can be sent only before any other output. This is a simple requirement and funny how big impact it may have on application architecture and how many tricky questions may be asked about it. Here is one from the Zend PHP 5 Certification Mock Exam.
You will find correct answer in bold.
One can ensure that headers can always be sent from a PHP script by doing what?
- Enable header buffering in PHP 5
- Set the header.force INI directive to true
- Enable output buffering in PHP 5
- There is no way to ensure that headers can always be set, they must always be checked
- None of the above
The header documentation page says: "As of PHP 4, you can use output buffering to get around this problem". That obviously makes sense on the contrary to header buffering suggested by the first answer. Header buffering would not help because the troublemaker here is premature output.
According to PHP manual there is no such directive as header.force and does not seem to have much sense as well, which shoots off the second answer.
The third one has some potential but is not correct - output buffering has been avaiable since PHP4.
And as output buffering seems to combat the problem successfully, the fourth answer is there only to trick you.