我已经安装了最新的 Simplepie 代码(1.2.1)并且我正在使用他们提供的演示代码:
<?php
require 'simplepie.inc';
$url = 'http://news.google.com/news?ned=us&topic=h&output=rss';
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->init();
// default starting item
$start = 0;
// default number of items to display. 0 = all
$length = 0;
// if single item, set start to item number and length to 1
if(isset($_GET['item']))
{
$start = $_GET['item'];
$length = 1;
}
// set item link to script uri
$link = $_SERVER['REQUEST_URI'];
// loop through items
foreach($feed->get_items($start,$length) as $key=>$item)
{
// set query string to item number
$queryString = '?item=' . $key;
// if we're displaying a single item, set item link to itself and set query string to nothing
if(isset($_GET['item']))
{
$link = $item->get_link();
$queryString = '';
}
// display item title and date
echo '<a href="' . $link . $queryString . '">' . $item->get_title() . '</a>';
echo ' <small>'.$item->get_date().'</small><br>';
// if single item, display content
if(isset($_GET['item']))
{
echo ' <small>'.$item->get_content().'</small><br>';
}
echo '<br>';
}
?>
但是,当我在浏览器中加载该页面时,我收到数十行内容:
Deprecated: Assigning the return value of new by reference is deprecated in /home/pliggs/public_html/rss/simplepie.inc on line 7722
有谁知道出了什么问题吗?
我运行了他们的兼容性测试,它显示所有事情都已通过。
这是 SimplePie 的 PHP 4 兼容性的结果,并且在您的代码中没有任何内容。如果您想不再看到这些错误,请排除E_DEPRECATED
从你的error_reporting
:
error_reporting(E_ALL & ~E_DEPRECATED);
如果您想自行修复错误,您可以从以下位置获取 SimplePie 1.3-dev(它会降低 PHP 4 兼容性)的副本GitHub https://github.com/simplepie/simplepie,但请记住这是一个开发版本并且不稳定。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)