title: Print the message of a response header on screen
body: <p>I am trying to send a custom response header from my web server to the browser and to print its <em>reason phrase</em> on the screen. Unfortunately this does not happen.</p>
  
  <p>My goal is to set an error handler (here: <code>errorHandler</code>) to display a user-friendly message to the user in all cases when an error is raised. So, not only when there is a "normal" HTTP request, but even if the request to the server is an ajax request.</p>
  
  <p>In the case of an ajax request, by doing this, I can, already, trigger the corresponding ajax "error" callback and print the <em>reason phrase</em> of the header in there, if an error occurs. But in the case of a "normal" request, like below, this doesn't work. E.g. no message is printed on the screen.</p>
  
  <p>Could you tell me, why not, and how I can solve this problem?</p>
  
  <p>Thank you.</p>
  
  <hr/>
  
  <p><strong>handlers.php:</strong></p>
  
  <pre><code>ini_set('log_errors', 1);
  error_reporting(E_ALL);
  ini_set('display_errors', 0);
  
  set_error_handler('errorHandler');
  
  function errorHandler($errno, $errstr, $errfile, $errline) {
      header('HTTP/1.1 420 An error occurred during your request. Please try again, or contact us.');
      error_log('Error ' . $errno . ' - ' . $errstr . ' in file ' . $errfile . ' on line ' . $errline);
      exit();
  }
  </code></pre>
  
  <p><strong>index.php:</strong></p>
  
  <pre><code>&lt;?php
  
  require 'handlers.php';
  
  // Because the function test() doesn't exist, an error is thrown.
  // But I see no message on screen.
  $tmnlid = test();
  </code></pre>