http_response_code
(PHP 5 >= 5.4.0)
http_response_code — Get or Set the HTTP response code
Beschreibung
int http_response_code
([ int
$response_code
] )If you pass no parameters then http_response_code will get the current status code. If you pass a parameter it will set the response code.
Parameter-Liste
-
response_code -
The optional
response_codewill set the response code.<?php
http_response_code(404);
?>
Rückgabewerte
The current response code. By default the return value is int(200).
Beispiele
Beispiel #1 Examples using http_response_code()
<?php
// Get the current default response code
var_dump(http_response_code()); // int(200)
// Set our response code
http_response_code(404);
// Get our new response code
var_dump(http_response_code()); // int(404)
?>
Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
Siehe auch
- header() - Sendet einen HTTP-Header in Rohform
- headers_list() - Gibt eine Liste der gesendeten (oder zum Senden vorbereiteten) Response Header zurück