Recently in the work needs to request a third-party Java version of the interface, the first is to use an array for the parameter, after the code is written to find that the interface is not debugging, always hint that the argument is empty, tangled for a long time, decided to try to use the method of string to request the interface, did not expect this actually debugging success, This gives me an interest in studying the difference between the two.
The local test code is as follows:
curl.php
functioncurl_post($url, $data){$ch= Curl_init (); curl_setopt ($ch, Curlopt_url,$url); curl_setopt ($ch, Curlopt_returntransfer,1); curl_setopt ($ch, Curlopt_post,1); curl_setopt ($ch, Curlopt_postfields,$data);$output= Curl_exec ($ch); Curl_close ($ch);return$output;}$params=Array();$params[' username '] =' Ben ';$params[' Password '] =' Lalala ';p Rint_r (Curl_post (' http://localhost/curl/post.php ',$params));$params=Array();$params[' username '] = UrlEncode (' Ben ');$params[' Password '] = UrlEncode (' Lalala ');$paramsStr="username={$params [' username ']}&password={$params [' Password ']}";p Rint_r (Curl_post (' http://localhost/curl/post.php ',$paramsStr));?>
post.php
echo"-------php://input-----
";var_dump(@file_get_contents('php://input'));echo"-------post-----
";var_dump($_POST);echo"-------server-----
";var_dump($_SERVER);
The execution results can be referred to as follows:
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
Copyright NOTICE: This article for Bo Master original article, reprint please indicate the source and author name, respect others also respect oneself
The above describes the PHP using Curl Post method string and the difference in the value of the array, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.