title: How to set Response status code and message while using REST api in php?
body: <p>product.php</p>
  
  <pre><code>&lt;?php
  class Product
  {
      private $conn;
      private $table_name = "category";
      public $image_name;
      public $file_s;
      public function __construct($db){
          $this-&gt;conn = $db;
      }
  
      function read()
      {
          $query = "SELECT * FROM ".$this-&gt;table_name." order by category_name";
          $stmt = $this-&gt;conn-&gt;prepare($query);
          $stmt-&gt;execute();
          return $stmt;
      }
  }
  </code></pre>
  
  <p>read.php</p>
  
  <pre><code>&lt;?php
      header("Access-Control-Allow-Origin: *");
      header("Content-Type: application/json; charset=UTF-8");
      include_once 'dbase.php';
      include_once 'product.php';
      $database = new Database();
      $db = $database-&gt;getConnection();
      $product = new Product($db);
      $stmt = $product-&gt;read();
      $num = $stmt-&gt;rowCount();
      if($num&gt;0)
      {
          $products_arr=array();
          $products_arr["data"]=array();
          while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC))
          {
              extract($row);
              $product_item=array(
                  "image_name" =&gt; $image_name,
                  "image_url" =&gt; $file_s
              );
  
              array_push($products_arr["data"], $product_item);
          }
  
          echo json_encode($products_arr);
      }
  
      else{
          echo json_encode(
              array("message" =&gt; "No products found.")
          );
      }
  ?&gt;
  </code></pre>
  
  <p>I have create a simple REST api which work perfectly but now the problem is that I don't have an any idea of Response code and Response message that how to add with REST api in php?</p>
  
  <p>Thank You </p>