PHP的卷曲问题

PHP的卷曲问题,php,curl,Php,Curl,以前,我一直在使用这个代码从BBC网站上通过CURL获取一些页面内容 $c = curl_init('http://news.bbc.co.uk/sport1/hi/football/eng_conf/conference_north_table/default.stm'); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $html = curl_exec ($c); if (curl_error($c))

以前,我一直在使用这个代码从BBC网站上通过CURL获取一些页面内容

    $c = curl_init('http://news.bbc.co.uk/sport1/hi/football/eng_conf/conference_north_table/default.stm');

    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    $html =  curl_exec ($c);
    if (curl_error($c))
        die(curl_error($c));

    $startpos = strpos($html, '<table border="1" cellpadding="1" cellspacing="0" class="fulltable">');

    $endpos = strpos($html, '<!-- E IINC -->');
    $length = $endpos - $startpos;
    $rest = substr($html, $startpos,$length);
    $rest = str_replace("border=\"1\" cellpadding=\"1\" cellspacing=\"0\"","border=\"0\" cellpadding=\"0\" cellspacing=\"0\"", $rest);
    $rest = str_replace('<tr><td colspan="15"><hr/></td></tr>',"", $rest);

    $rest = str_replace('<tr>
      <td colspan="15">
         <div style="padding: 10px 0 0 0;"><img src=" http://newsimg.bbc.co.uk/sol/shared/img/tbl_spc.gif" height="2px" width="100%"></div>
      </td>
   </tr>
',"", $rest);

    echo $rest;
    curl_close($c);
$c=curl\u init('http://news.bbc.co.uk/sport1/hi/football/eng_conf/conference_north_table/default.stm');
curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
$html=curl_exec($c);
if(旋度误差($c))
模具(旋度误差($c));
$startpos=strpos($html,”);
$endpos=strpos($html,”);
$length=$endpos-$startpos;
$rest=substr($html,$startpos,$length);
$rest=str\u replace(“border=\'1\'单元格填充=\'1\'单元格间距=\'0\',“border=\'0\'单元格填充=\'0\'单元格间距=\'0\',$rest);
$rest=str_replace(“
”、“,$rest”); $rest=str_替换($rest) “,”,$rest); 回音$rest; 收尾费($c);
以前,在旧的服务器上使用PHP5.1.3可以很好地工作,我们已经将站点迁移到运行5.4.8的服务器上,但是上面的代码不再工作了,有什么原因吗?我看不出有什么问题

如果我在
$html
处终止脚本,我会得到以下响应

排行榜

永久移动

文件已移到这里


但是,如果我通过浏览器导航到URL,我可以很好地查看页面,因此它显然没有移动到任何地方(这是因为在我们迁移服务器之前,Curl请求正在工作)。

地址实际上已经移动。请使用以下命令更改第一行:

$c = curl_init('http://news.bbc.co.uk/sport2/hi/football/eng_conf/conference_north_table/default.stm');
上面的代码现在向我显示了结果表。

您必须使用

curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
跟随重定向


查看选项的完整列表。

有错误消息吗?是否插入了调试语句以查看值是什么样子的?什么是“不再工作”的确切含义?@OlafDietsche请查看我的编辑。始终将块代码放在
{}
括号中是一个好习惯。即使是像
if(curl_error($c))这样的一行程序..
-这样的习惯可以在不太期望的时刻避免你的麻烦。可能是试图重定向到另一个页面而没有完成。尝试?尝试使用curl_info()查看任何信息