分别用了curl和file_get_contents均无法获取到内容,替换网址后就可以了,具体如下:
<?php
function getwebcontent($url){
$ch = curl_init();
$timeout = 10;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$contents = trim(curl_exec($ch));
curl_close($ch);
return $contents;
}
//$temps='http://127.0.0.1:50/admin/process_get.php?k=get&s=11&i=12367&url=www.100.com';
//$chS=file_get_contents($temps);
$chS=getwebcontent('http://127.0.0.1:50/admin/process_get.php?k=get&s=11&i=12367&url=www.100.com');
echo $chS;
?>
我的远程网址http://127.0.0.1:50/admin/process_get.php?k=get&s=11&i=12367&url=www.100.com 是可以访问的,内容为77788899
但通过curl和file_get_contents获取此网址均无法获取内容,导致服务器卡死,将上述网址替换为其他的网址,一切正常!!
老板说了,这个问题解决不掉,明天不让回家过年,请各位帮忙看看!!!