PHP PHP中的cURL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP PHP中的cURL相关的知识,希望对你有一定的参考价值。

/**
 * cURL file copy to another server
 * This file saved my life when i had to let a file upload synchrom to a different server, no ftp messing around!
 */
$rCurl = curl_init();
 
/**
 * The file to copy
 */
curl_setopt($rCurl, CURLOPT_URL, 'http://www.google.nl/intl/nl_nl/images/logo.gif');
 
/**
 * cURL options dunno what for
 */
curl_setopt($rCurl, CURLOPT_HEADER, false);
 
/**
 * cURL options dunno what for
 */
curl_setopt($rCurl, CURLOPT_BINARYTRANSFER, true);
 
/**
 * cURL options dunno what for
 */
curl_setopt($rCurl, CURLOPT_RETURNTRANSFER, true);

 
/**
 * The php file limit
 */
set_time_limit(300);
 
/**
 * set cURL timeout
 */
curl_setopt($rCurl, CURLOPT_TIMEOUT, 300);

 
/**
 * The file that will be written
 */
$rOutPut = fopen('googlelogo.gif', 'wb');
 
/**
 * Setup the transfer ?
 */
curl_setopt($rCurl, CURLOPT_FILE, $outfile);

 
/**
 * Execute the transfer
 */
curl_exec($rCurl);
 
/**
 * Close the file
 */
fclose($rOutPut);

 
/**
 * Close cURL
 */
curl_close($rCurl);

以上是关于PHP PHP中的cURL的主要内容,如果未能解决你的问题,请参考以下文章

PHP PHP中的cURL

怎样用php中的curl模拟登陆

PHP中的cURL库

更改 php(xampp) 中的 curl 扩展名?

php中的cURL不起作用

php中的curl使用入门教程和常见用法实例