symcbean's answer is correct by the book, but not always in practice. Even though you shouldn't create output in a shutdown handler, you can do so under select circumstances.
Check out headers_sent(). In your shutdown function, check it. If headers have not been sent yet, then you can echo new headers and actual content if needed. You can use error_get_last() to determine if the shutdown is due to an error or not. The following error types are uncatchable and will kill the script and call shutdown functions:
- E_ERROR
- E_PARSE
- E_CORE_ERROR
- E_COMPILE_ERROR
If the error type is one of those, and headers haven't been sent, then your shutdown handler can create output, including headers.
You must not create output from a shutdown handler if headers have been sent. Those headers could include Content-length, and sending more content than you said you would is bad. Even then, if headers have been sent, any output you create may have nowhere to go, depending on the version of PHP being used, the underlying web server software, and whether or not it's FastCGI.
In fact, this answer may be totally bogus outside of mod_php and FastCGI on Apache 2.2.x. YMMV, but good luck.