For an experienced
(a) Form post mode of submission PHP get post data
$_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
(ii) Fsockopen submit post data PHP get post data
- $ sock = Fsockopen ("localhost", 80,
$errno, $ERRSTR, 30);
- if (! $sock) Die ("$errstr ($errno) n");
- $ Data = "txt=" . UrlEncode ("Medium").
"&bar=". UrlEncode ("Value for Bar");
- Fwrite ($sock, "post/posttest/response
. PHP Http/1.0rn ");
- Fwrite ($sock, "host:localhostrn");
- Fwrite ($sock, "Content-type:applicat
Ion/x-www-form-urlencodedrn ");
- Fwrite ($sock, "Content-length:".)
Strlen ($data). "RN");
- Fwrite ($sock, "Accept: */*rn");
- Fwrite ($sock, "RN");
- Fwrite ($sock, "$datarn");
- Fwrite ($sock, "RN");
- $ Headers = "" ;
- While ($str = trim(fgets ($sock,
4096)))
- $headers . = "$strn" ;
- echo "n";
- $ Body = "" ;
- while (!feof ($sock))
- $body . = fgets ($sock, 4096);
- Fclose ($sock);
- Echo $body;
PHP get Post Data 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 can implement PHP to get post data only when data is submitted by application/x-www-form-urlencoded type.
http://www.bkjia.com/PHPjc/445978.html www.bkjia.com true http://www.bkjia.com/PHPjc/445978.html techarticle for an experienced (one) Form post submission case PHP gets post data $_post with Php://input can fetch value, $HTTP _raw_post_data is empty $_post in associative array mode ...