无法使用PHP

时间:2017-02-15 22:43:09

标签: php html rss

我想使用其RSS源和PHP语言获取新闻网站,函数getFeed()通常会使用file_get_contents($url)为我做以下操作:

<?php 
function getFeed() {
$content = file_get_contents('http://echoroukonline.com/ara/feed/index.rss');
$content = simplexml_load_string($content);
print_r($data);   
}
?>

我在<div>元素的html页面上调用此函数,我的html页面如下所示:

<?php

include('core/init.inc.php');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <title>Bienvenu</title>
        <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
    </head>

    <body>

        <div>
            <?php
                getFeed();
            ?>
        </div>
    </body>
</html>

我在这个网页上加入了一个初始化函数:

<?php

$path=dirname(__FILE__);

include("{$path}/inc/rssnews.inc.php");

?>

但是当我在导航器上运行此页面时,我没有得到网站RSS源的显示,我只是显示了html页面。 那么,我怎么能解决这个问题并阅读我网站的RSS源?

0 个答案:

没有答案
相关问题