English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The http_response_code() function retrieves/sets the HTTP response status code.
int http_response_code ([ int $response_code ] )
It is used to get or set the HTTP response
If response_code is provided, it returns the previous status code. If response_code is not provided, it returns the current status code. In the Web server environment, the default values for these status codes are all 200.
If response_code is called in a non-Web server environment (such as CLI applications), FALSE is returned if response_code is not provided. In non-Web server environments, providing response_code returns TRUE (only if the status code has not been set previously).
Serial Number | Parameters and Description |
---|---|
1 | response_code The optional response_code sets the response status code. |
Try the following example
<?php var_dump(http_response_code()); http_response_code(404); ?>
The above code sets the response code to 404.
bool(false)