PHP | http_response_code() Function

PHP http_response_code() Function


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP http_response_code() Function.

The built-in http_response_code() function is used to get or set the HTTP Response.

Syntax

Following below is the syntax to use this function -

int http_response_code ([ int $response_code ] )


Parameter Details

Sr.NoParameters & Description
1

response_code

The response code should be an integer.


Return Value

This function returns the response code, by default the return value is int(200).

Example

Try out the following example below -

<?php
   var_dump(http_response_code());  
   http_response_code(404);
?>

Output

When the above code is executed, it will produce the following result below -

bool(false)


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the PHP inet_ntop() Function.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Do follow us on our various social media handles available and also subscribe to our newsletter to get our tutorial posts delivered directly to your emails.

Thanks for reading and bye for now.