|
curl_copy_handle
Copy a cURL handle along with all of its preferences
(PHP 5)
Example 429. Copying a cURL handle<?php Code Examples / Notes » curl_copy_handleandrew
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); ?> |