Curl supports SSL certificates, HTTP POST, http PUT, FTP uploads, Kerberos, HTT-based uploads, proxies, cookies, user + password proofs, file transfer recovery, HTTP proxy channels for the most common use, is an HTTP-based get and post method.
Code implementation:
1. Get implementation of HTTP
Copy the Code code as follows:
$ch = Curl_init ("http://www.jb51.net/");
curl_setopt ($ch, Curlopt_returntransfer, true);
curl_setopt ($ch, Curlopt_binarytransfer, true);
$output = curl_exec ($ch);
$fh = fopen ("out.html", ' W ');
Fwrite ($FH, $output);
Fclose ($FH);
2, the HTTP POST implementation
Copy the Code code as follows:
//extract data from the post
Extract ($_post);
//set POST variables
$url = ' http://www.jb51.net/get-post.php ';
$fields = Array (
' lname ' =>urlencode ($last _name),
' fname ' =>urlencode ($first _name),
' title ' = >urlencode ($title),
' Company ' =>urlencode ($institution),
' age ' =>urlencode ($age),
' email ' = UrlEncode ($email),
' phone ' =>urlencode ($phone)
);
//url-ify The data for the POST
foreach ($fields as $key = = $value) {$fields _string. = $key. ' = '. $value. ' & '; }
RTrim ($fields _string, ' & ');
//open connection
$ch = Curl_init ();
//set the URL, number of post VARs, post data
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_post,count ($fields));
curl_setopt ($ch, Curlopt_postfields, $fields _string);
//execute post
$result = curl_exec ($ch);
//close Connection
Curl_close ($ch);
The above describes the Portfree production program PHP's curl implementation of get and post code, including Portfree production program aspects of the content, I hope the PHP tutorial interested in a friend helpful.