Compare the differences between form post and Fsockopen submission in two different ways.
Form Post Mode submission case
$_post and Php://input can fetch a value, $HTTP _raw_post_data is empty
$_post organizes the submitted data in an associative array, and encodes it, such as UrlDecode, or even transcoding.
Php://input can get unprocessed post raw data via input stream in file read mode
Php://input allows the raw data to be read from the POST. Compared to $HTTP _raw_post_data, it brings less pressure to memory and does not require any special php.ini settings. Php://input cannot be used for enctype= "Multipart/form-data".
Fsockopen Submit Post Data
Cases:
$sock = Fsockopen ("localhost", $errno, $errstr, 30);
if (! $sock) Die ("$errstr ($errno)");
$data = "txt=". UrlEncode ("Medium"). "&bar=". UrlEncode ("Value for Bar");
Fwrite ($sock, "post/posttest/response.php http/1.0");
Fwrite ($sock, "host:localhost");
Fwrite ($sock, "content-type:application/x-www-form-urlencoded");
Fwrite ($sock, "Content-length:".) Strlen ($data). "");
Fwrite ($sock, "Accept: */*");
Fwrite ($sock, "");
Fwrite ($sock, "$data");
Fwrite ($sock, "");
$headers = "";
while ($str = Trim (fgets ($sock, 4096))
$headers. = "$str";
echo "";
$body = "";
while (!feof ($sock))
$body. = Fgets ($sock, 4096);
Fclose ($sock);
Echo $body;
Consistent with (i) results
Conclusion:
1. Php://input can be easily taken to the original post data
2. $HTTP _raw_post_data only valid if the Content-type type of POST is not recognized by PHP
If post data is normally submitted through the page form, it cannot be extracted via $http_raw_post_data. Because of its encoding type attribute (Enctype property) is application/x-www-form-urlencoded, Multipart/form-data.
Note: Even if the Enctype property is explicitly changed within the page to be an unrecognized type for PHP, it is still invalid.
Because the form submission encoding attribute is form-qualified, the unrecognized type is considered to be committed by default encoding (that is, application/x-www-form-urlencoded)
3. $_post is only available when data is submitted by application/x-www-form-urlencoded type.
http://www.bkjia.com/PHPjc/508353.html www.bkjia.com true http://www.bkjia.com/PHPjc/508353.html techarticle compare the differences between form post and Fsockopen submission in two different ways. The form POST method submits the case $_post and php://input can take the value, $HTTP the _raw_post_data is the empty $_post to associate the number ...