PHP script to retrieve raw HTTP data using php input (“php://input”)

Today, We want to share with you php input.In this post we will show you Checking for “php://input” AND $_POST, hear for file_get_contents(“php://input”) or $HTTP_RAW_POST_DATA, which one is better to get the body of JSON request? we will give you demo and example for implement.In this post, we will learn about PHP CURL HTTP Request (GET & POST) with an example.

How do you access the php://input stream?

The php://input Data contains the raw data from a POST HTTP request, And then all of the HTTP headers. You can think of http simple $_POST as the same data (…sometimes) that has been parsed into an array.

Read Also:  Codeigniter recaptcha form validation - Google recaptcha

php://input gets the raw data. here The stream can be accessed in the following method using PHP:

get the raw POST data

$response = file_get_contents("php://input");
//put in log file

The PHP script to retrieve raw HTTP data is as follows −

$json = file_get_contents("php://input");
$data = json_decode($json);

I hope you get an idea about check Empty – NULL in php.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.