: This article mainly introduces the differences between CURLOPT_POSTFIELDS using arrays and strings in PHPcURL. For more information about PHP tutorials, see. We use the following two variables to perform the cURL POST test respectively:
'Apple']; // String $ str_data = '{"a": "apple "}';
The following is the result printed from the server:
The preceding figure is parsed from the $ _ SERVER ['content _ type'], $ _ POST variable, and php: // input.CURLOPT_POSTFIELDSDifferences between arrays and strings.
Finally, we can draw a conclusion:
1) when using arrays
- The Content-Type of the HTTP request header will be set to multipart/form-data;
- The array content can be obtained from $ _ POST;
- The use of file_get_content ("php: // input") is null. for this purpose, the PHP Manual also says:
Php: // input is not available with enctype = "multipart/form-data"
2) when using strings
- The Content-Type of the HTTP request header is set to application/x-www-form-urlencoded;
- The string content is changed to the key of an element in $ _ POST;
- The string content can be obtained from php: // input;
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above introduces the differences between using arrays and strings in CURLOPT_POSTFIELDS of PHP cURL, including some content, and hope to help friends who are interested in PHP tutorials.