'PHP CURL about curl_multi_getcontent overflow
I am use curl connect and use keep alive.When I use curl_multi_getcontent to get data that will display history data in return.
Is it will have problem for example variable overflow? I have searched information that php variable can request size about 2GB. Or any method can solve it? for example disconnect then reconnect to clear curl_multi_getcontent's data?
Because I continue run script now and without any problem. But I don't know script run long away will have problem? below my code
<?php
set_time_limit(0);
$ch = create();
$mh = curl_multi_init();
curl_multi_add_handle($mh, $ch);
$old_data = "";
$data_len = 0;
$running=null;
curl_multi_select($mh);
$active = null;
// execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
}while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
echo str_repeat(" ",1024*5);
$data = curl_multi_getcontent($ch);
$pattern = "/--\w*/";
preg_match_all($pattern, $data, $matches);
if(sizeof($matches[0]) > 0)
{
$split_txt = $matches[0][sizeof($matches)-1];
$data_list = explode ($split_txt,$data);
$data_len = count($data_list);
if($data_len >=2 && $old_data !== $data_list[$data_len-2])
{
$old_data = $data_list[$data_len -2];
$time_pattern = "/-\d{19}/";
preg_match($time_pattern, $old_data, $time_matches);
$time = $time_matches[0];
echo($old_data."<br>");
$write_txt = time_covert($time).": ".$old_data;
$file = fopen("output.txt","a");
fwrite($file,$write_txt);
fclose($file);
}
}
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
