title: PHP best way to return custom message with header status code
body: <p>Where is the best place to put a custom response message. I will need to access the response message with jquery and alert it to the user</p>
  
  <pre><code>function return_status($code, $message) {
  
  
  
      //This way
      header("HTTP/1.1 $code $message");
      die();
  
     //OR This way
     header('Content-Type: application/json');
     header("HTTP/1.1 $code");
     die(json_encode(['code' =&gt; $code, 'message' =&gt; $message]));
  }
  </code></pre>