PHP's Curl implementation get and post_php tutorials

Source: Internet
Author: User
Tags http post ldap urlencode
Similar to dreamhost such as host service providers, is to display the use of fopen. Use of PHP's curl can be implemented to support FTP, FTPS, HTTP htpps SCP SFTP TFTP, TELNET DICT file and LDAP. 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

The following is the referenced content:
$ch = Curl_init ("http://www.webjx.com/");
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

//extract data from the post
Extract ($_post);
//set POST variables
$url = ' http://www.webjx.com/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);

http://www.bkjia.com/PHPjc/364043.html www.bkjia.com true http://www.bkjia.com/PHPjc/364043.html techarticle similar to dreamhost such as host service providers, is to display the use of fopen. Use of PHP's curl can be implemented to support FTP, FTPS, HTTP htpps SCP SFTP TFTP, TELNET DICT file and LDAP. Curl Support S ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.