Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用php获取RSS内容_Php_Rss - Fatal编程技术网

无法使用php获取RSS内容

无法使用php获取RSS内容,php,rss,Php,Rss,我正在尝试使用php阅读RSS提要。我开发了这段代码,它在本地XAMPP服务器上运行良好,但当我将其上载到Web服务器时,它无法获取任何内容,也不会生成任何错误 <?php try { //Read the RSS content $rss = new DOMDocument(); $rss->load('http://properstatus.com/rss.php'); $feed = array(); foreach ($rss->getE

我正在尝试使用php阅读RSS提要。我开发了这段代码,它在本地XAMPP服务器上运行良好,但当我将其上载到Web服务器时,它无法获取任何内容,也不会生成任何错误

<?php
try {
//Read the RSS content
    $rss = new DOMDocument();
    $rss->load('http://properstatus.com/rss.php');
    $feed = array();
    foreach ($rss->getElementsByTagName('item') as $node) {
        $item = array(
            'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
            'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue
        );
array_push($feed, $item);
    }


    $limit = 6;
    $link = "http://bit.ly/1HmbPn4 ";
    for ($x = 0; $x < $limit; $x++) {
        $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
        $description = $feed[$x]['desc'];
        $payload = $title . "..." . $link;
        echo "Desc: " . $description . "<br/>";        
    }
} catch (Exception $ex) {
    echo $ex->getMessage();
    die();
}
?>

你能发现代码中有什么错误吗?或者可能是版本冲突?本地主机运行PHP5.5.15,服务器运行PHP5.5.20


备注:代码已上传,可在不
array\u push($feed,$item)进行现场测试属于它上面的循环。@JimGarrison是的,你是对的,我在格式化代码时似乎犯了这个错误,谢谢你,我会编辑它。虽然@JimGarrison页面仍然加载为空,但没有解决这个问题,我不知道这里可能有什么问题