Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : CURL, Client URL Library Functions : curl_copy_handle

curl_copy_handle

Copy a cURL handle along with all of its preferences (PHP 5)
resource curl_copy_handle ( resource ch )

Example 429. Copying a cURL handle

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/');
curl_setopt($ch, CURLOPT_HEADER, 0);

// copy the handle
$ch2 = curl_copy_handle($ch);

// grab URL (http://www.example.com/) and pass it to the browser
curl_exec($ch2);

// close cURL resources, and free up system resources
curl_close($ch2);
curl_close($ch);
?>

Code Examples / Notes » curl_copy_handle

andrew

You can use it for some kind of templates:
<?php
$ch = array();
$ch[0] = curl_init();
curl_setopt($ch[0], CURLOPT_URL, 'http://beengo.net/');
curl_setopt($ch[0], CURLOPT_HEADER, 0);
curl_setopt($ch[0], CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch[0], CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch[0], CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$ch[1] = curl_copy_handle($ch[0]);
curl_setopt($ch[1], CURLOPT_URL, 'http://beengo.net/cells/list');
$ch[2] = curl_copy_handle($ch[0]);
curl_setopt($ch[2], CURLOPT_URL, 'http://beengo.net/cells/list?q=travel');
/* And so on, when you need to get number of pages with same parameters... */
?>


nicolac76

Something work wrong if you use the var $i for a for...
$i cannot go over 127 (0111 1111b), more over you must say that the var is an int...
<?
$j=(int)0;
$curl = curl_init("http://www.example.com");
for($j=1;$j<=128;$j++) {
$ch = curl_copy_handle($curl);
curl_close($ch);
}
curl_close($curl);
?>


Change Language


Follow Navioo On Twitter
Constants
curl_close
curl_copy_handle
curl_errno
curl_error
curl_exec
curl_getinfo
curl_init
curl_multi_add_handle
curl_multi_close
curl_multi_exec
curl_multi_getcontent
curl_multi_info_read
curl_multi_init
curl_multi_remove_handle
curl_multi_select
curl_setopt_array
curl_setopt
curl_version
eXTReMe Tracker