使用Simplepie弃用错误 [英] Getting deprecated error with Simplepie
本文介绍了使用Simplepie弃用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经安装了最新的Simplepie代码(1.2.1),并且正在使用它们提供的演示代码:
I have installed the latest Simplepie code (1.2.1) and I am using the demo code they provide:
<?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>';
}
?>
但是,当我在浏览器中加载页面时,我会看到数十行内容:
However, when I load the page in my browser, I get dozens of lines saying:
Deprecated: Assigning the return value of new by reference is deprecated in /home/pliggs/public_html/rss/simplepie.inc on line 7722
有人知道怎么了吗?
我进行了他们的兼容性测试,结果表明所有事情都已通过.
I ran their compatibility test and it shows all things have passed.
推荐答案
您需要在代码中查找"=& new"的每个实例,然后删除&"现在已弃用.该代码中大约有116次出现.它与对象实例化的副本和引用有关.
You need to find every instance of "=& new" in the code and delete the "&" which is now deprecated. There are approximately 116 occurrences in the code. It has to do with copies and references of object instantiation.
这篇关于使用Simplepie弃用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文