How to get or set the HTTP response code in PHP

3 Answers

0 votes
// mixed http_response_code ([ int $response_code ] )

var_dump(http_response_code());


/*
run:

int(200) 

*/

 



answered Jun 28, 2016 by avibootz
0 votes
// mixed http_response_code ([ int $response_code ] )

http_response_code(404);

/*
run:

The webpage cannot be found 
 HTTP 404 
...

*/

 



answered Jun 28, 2016 by avibootz
0 votes
// mixed http_response_code ([ int $response_code ] )

http_response_code(201);

var_dump(http_response_code());

/*
run:

int(201) 

*/

 



answered Jun 28, 2016 by avibootz

Related questions

...