我在本地和服务器上运行相同的代码。但是,相同的代码在本地而不是服务器端运行。没有显示错误。
$contents = '';
if (function_exists('curl_init'))
{ // first check with curl as we can set short timeout;
$retry = 1;
do {
$check = _isCurl();
// display_error( _("version: " . $check));
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://'.$site.$filename);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "$path_to_root/tmp/cookie.txt");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// prevent warning while safe_mode/open_basedir on (redireciton doesn't occur at least on ECB page)
if (!ini_get('safe_mode') && !ini_get('open_basedir'))
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 3);
$contents = curl_exec ($ch);
curl_close($ch);
// due to resolver bug in some curl versions (e.g. 7.15.5)
// try again for constant IP.
if (isset($site_ip))
{
// display_error( _("in " . $site_ip));
$site=$site_ip;
}
} while( ($contents == '') && $retry--);
我试图运行curl_getinfo($ ch);
本地
数组([url] =&gt; myURL [content_type] =&gt; text / xml [http_code] =&gt; 200 [header_size] =&gt; 237 [request_size] =&gt; 91 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 0 [total_time] =&gt; 0.016 [namelookup_time] =&gt; 0.016 [connect_time] =&gt; 0.016 [pretransfer_time] =&gt; 0.016 [size_upload] =&gt; 0 [ size_download] =&gt; 1624 [speed_download] =&gt; 0 [speed_upload] =&gt; 0 [download_content_length] =&gt; 0 [upload_content_length] =&gt; 0 [starttransfer_time] =&gt; 0.072781 [redirect_time] =&gt; 0)< / p>
服务器
数组([url] =&gt; myURL [content_type] =&gt; [http_code] =&gt; 0 [header_size] =&gt; 0 [request_size] =&gt; 0 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 0 [total_time] =&gt; 3.003278 [namelookup_time] =&gt; 7.0E- [connect_time] =&gt; 5 [pretransfer_time] =&gt; 0 [size_upload] =&gt; 0 [size_download ] =&gt; 0 [speed_download] =&gt; 0 [speed_upload] =&gt; 0 [download_content_length] =&gt; 0 [upload_content_length] =&gt; 0 [starttransfer_time] =&gt; 0.072781 [redirect_time] =&gt; 0)