jeudi 23 mai 2019

My php server always returns a 200 status code. But returns with http codes locally

I have a php api which is supposed to return responses with status codes. But returns only a 200 response code. This works when tested locally with Xampp but not a on live deployment server. On the deployment server i have tried :

  • header(':',true,$code);
  • http_response_code(404);
  • header("Status: 404 Not Found");
  • header('X-PHP-Response-Code: '.$code, true, $code);

Based on previous answers on stack overflow

`public function echoResponse($code, $response){

header(':',true,$code);  
echo json_encode($response);
exit();

}`

i keep getting a response code of 200.




Aucun commentaire:

Enregistrer un commentaire