-4

To those who have already installed PHP 7, and it works fine when you give PHP 7 code, please check my PHP 7 code and tell me if it works with you, (this code came from a book.) if it does not work then tell me how I could fix it, then if it does work, then tell me what else I have to install or do. This is the PHP 7 code:

<!DOCTYPE html>
<html>
<head>
<title> Luke Reports | Home </title>
</head>
<body>
<?php
$url = 'http://rss.news.yahoo.com/rss/entertainment';
$xml =
simplexml_load_file( $url ) or die( 'Unalble to load data!');
include( 'includes/rss-footer.html');
foreach( $xml->channel->item as $item){
echo '<a href="'.item->link.'">'.$item->title.'</a>';
echo '<br><small>'.$item->pubDate.'</small><br>';
echo $item->description.'<hr>';}
include( 'includes/rss-footer.html');
?>
</body>
</html>

So I will highly appreciate it if you comment or Answer.

Thanks, Luke

Luke
  • 9
  • 1
  • 5

1 Answers1

1

I ran the code, you forget a '$' on line 13 as PHP told me:

Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in /var/www/html/MYPATH/test.php on line 13"

It's echo '<a href="'.$item->link.'">'.$item->title.'</a>';

Make sure you activated a verbose PHP for debugging.

BuzzRage
  • 184
  • 1
  • 12