This article has been the main example.
demo1.php
<?php $user="admin123"; $pass="admin456"; //$curlPost = "user= $user &pass= $pass"; # # # Test A
###### Test Two
$curlPost =Array ('a'=123, 'b'=456, 'C'=789 ); $ch= Curl_init ();//Initialize a Curl objectcurl_setopt ($ch, Curlopt_url,"Demo2. PHP"); //set the URL that you want to crawlcurl_setopt ($ch, Curlopt_returntransfer,0); //set the curl parameter to ask if the result is output to the screen, true when it is not returned to the Web page//assuming that the above 0 is replaced with 1, then the next $data needs echo. curl_setopt ($ch, Curlopt_post,1); //Post Submissioncurl_setopt ($ch, Curlopt_postfields, $curlPost); $data=curl_exec ($ch); //Echo $data; //Run Curl and request the Web page. curl_close ($ch);?>
View results:
<? PHP // echo "AAAAA"; Echo "<pre>"; Var_dump ($_post); Echo "<br/>"; Echo $_post [' B ']; Echo "<br/>"; $a Array (' 1 ' =>1234, ' 2 ' =>567); Var_dump ($a);? >
Introduction to PHP curl_setopt function usage Medium