PHP http_response_code() Function

❮ PHP Network Reference

Example

Set the HTTP response status code to 404:

<?php
http_response_code(404);
?>


Definition and Usage

The http_response_code() function sets or returns the HTTP response status code.

Syntax

http_response_code(code)

Parameter Values

Parameter Description
code Optional. Specifies a response code (like 404)

Technical Details

Return Value: If code is set, the previous status code is returned. If code is not set, the current status code is returned
PHP Version: 5.4+

❮ PHP Network Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.