Contrary to the the note that "headers are always sent" and some of the comments below - You CAN use header() inside of a shutdown function as you would anywhere else; when headers_sent() is false. You can do custom fatal handling this way:
<?php
ini_set('display_errors',0);
register_shutdown_function('shutdown');
$obj = new stdClass();
$obj->method();
function shutdown()
{
if(!is_null($e = error_get_last()))
{
header('content-type: text/plain');
print "this is not html:\n\n". print_r($e,true);
}
}
?>