For PHP 4.0:
to send an HTTP response code, we need to collect a response code. To do this, use the header() function. The header() function contains a special use case that can detect an HTTP response string and replace it with a custom one.
header ("HTTP / 1.1 200 OK"); Example :
For PHP 4.3:
, 0, 3) ==
" Status: 404 Not Found "
" HTTP / 1.1 404 Not Found "
there are obviously several problems with the first method. The biggest is that it is partially parsed by PHP and poorly documented. Since version 4.3, the header() function has an additional 3rd argument with which we can set the response code. but there must be a non-empty string to use the first argument.
header (`:`, true, 400); header (`X_PHP_Response_Code: 400`, true, 400);
The second is recommended. The header field name in this version is not standardized and can be changed.For PHP 5.4:
this version uses the http_response_code() function to make things easier.
http_response_code (400); Example:
This example uses the http_response_code() function to send the HTTP response code.
(E_ERROR | E_PARSE);
// Initialize the variable to the domain name
` https://contribute.engineerforengineer.org `
// Function for getting the HTTP response code
= get_headers (
, 9, 3);
// function call
= get_http_response_code (
// Show HTTP response code
// Check the HTTP 200 response code or not
" < br > HTTP request successfully "
" < br > HTTP request not successfully! "
200 HTTP request successfully