php set http code

Solutions on MaxInterview for php set http code by the best coders in the world

showing results for - "php set http code"
Valentina
12 Nov 2016
1/* Example #1 Using http_response_code() in a web server environment
2--------------------------------------------------------------------*/
3// Get the current response code and set a new one
4var_dump(http_response_code(404));  // output: 200
5// Get the new response code
6var_dump(http_response_code());     // output: 404
7
8/* Example #2 Using http_response_code() in a CLI environment
9-------------------------------------------------------------*/
10// Get the current default response code
11var_dump(http_response_code());     // output: false
12// Set a response code
13var_dump(http_response_code(201));  // output: true
14// Get the new response code
15var_dump(http_response_code());     // output: 201