0

I would like to fetch a news website using its RSS feed and PHP language, the function getFeed() normally will do that for me using file_get_contents($url) as follow:

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

I call this function on my page html on a <div> element, my html page look like:

<?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>

I include on this webpage an initialization function:

<?php

$path=dirname(__FILE__);

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

?>

But when I run this page on the navigator I don't get the display of the RSS feed of the website, I just get the html page as it is shown. So, how could I solve this problem and read the RSS feed of my website?

Ha KiM's
  • 119
  • 1
  • 1
  • 13
  • Any error in the log? – Ad5001 Feb 15 '17 at 22:46
  • When you view source, do you see the `` part? – Mike Feb 15 '17 at 22:47
  • @Ad5001Gameurcodeurautre yes i get just the html page as it is shown, I don't get the rss feed page – Ha KiM's Feb 15 '17 at 22:50
  • @Mike yes this code is to call the function `getFeed()` on the `
    `element, in other words, i want to bring the rss to the div element
    – Ha KiM's Feb 15 '17 at 22:52
  • @HaKiM's Look at the source with your browser (mostly CTRL (or CMD on a mac) + MAJ + I) and look at src shown in your browser. What do you see in the dir where the feed should appear? – Ad5001 Feb 15 '17 at 22:53
  • @Ad5001Gameurcodeurautre I don't see anything just the source code as I pasted here – Ha KiM's Feb 15 '17 at 22:59
  • You called your php script an html page a few times, what extension does the php page have? If it has an html extension, then the php compiler is not being run against it by the server, because it doesn't know the file is a php page. If it has a php extension, you should go the route of Mike's comment about php code not being executed. – Andy Arndt Feb 15 '17 at 23:01
  • @AndyArndt Thank you, but the page extension is on php – Ha KiM's Feb 15 '17 at 23:03
  • @HaKiM's So you see in the source the PHP code? Is the file extension a .php? If so, are you sure PHP is installed on your web server? – Ad5001 Feb 15 '17 at 23:06
  • @Ad5001Gameurcodeurautre yes I guess the problem was on the server, thank you bro I appreciate that – Ha KiM's Feb 15 '17 at 23:10

0 Answers0