Php: // What is the difference between input and $ _ POST in php?

Source: Internet
Author: User
Tags http post http request ini

Let's first look at two instances.

Example: php: // input

The code is as follows: Copy code

<Form action = "post. php" method = "post">
<Input type = "text" name = "user">
<Input type = "password" name = "password">
<Input type = "submit">

Post. php

The code is as follows: Copy code

<? Echo file_get_contents ("php: // input");?>

Example: post


The code is as follows: Copy code

<Form action = "welcome. php" method = "post">
Enter your name: <input type = "text" name = "name"/>
Enter your age: <input type = "text" name = "age"/>
<Input type = "submit"/>

Welcome. php

The code is as follows: Copy code
Welcome <? Php echo $ _ POST ["name"];?>. <Br/>
You are <? Php echo $ _ POST ["age"];?> Years old!

Variables sent through http post are not displayed in the URL.

When we use $ _ POST to receive the information transmitted from the page, we can use php: // input to accept the value. What is the difference between them?

First, when $ _ POST and php: // input can get the value, $ HTTP_RAW_POST_DATA is blank;
$ Http_raw_post_data is a built-in global variable in PHP. It is used. PHP fills in the POST data as is in the variable $ http_raw_post_data when the Content-Type cannot be recognized. It cannot read POST data whose Content-Type is multipart/form-data. You need to set the always_populate_raw_post_data value in php. ini to On, and PHP will always fill in the POST data with the variable $ http_raw_post_data.

Then $ _ POST organizes the submitted data in an associated array and performs encoding, such as urldecode or even encoding conversion;
Php: // input: raw POST data that has not been processed is obtained by reading files through the input stream;

Php: // input allows reading original POST data. Compared with $ HTTP_RAW_POST_DATA, it puts less pressure on the memory and does not require any special php. ini settings. Php: // input cannot be used for enctype = "multipart/form-data ";

Php: // input cannot read $ _ GET data. The reason is that the $ _ GET data is written in the PATH field of the http request header as query_path, rather than in the http request body.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.