Syntax rss解析函数中的PHP解析错误
我有一个客户迫切需要一个网站,但我无法访问控制面板等信息 PHP版本是4.4,这是一个痛苦,因为我习惯了5。 第一个问题是我不断地得到:Syntax rss解析函数中的PHP解析错误,syntax,php4,feedparser,Syntax,Php4,Feedparser,我有一个客户迫切需要一个网站,但我无法访问控制面板等信息 PHP版本是4.4,这是一个痛苦,因为我习惯了5。 第一个问题是我不断地得到: Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in D:\hshome\*******\********\includes\functions.php on line 37 这就是所讨论的功能: function read_rss($display=0,$url='
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in D:\hshome\*******\********\includes\functions.php on line 37
这就是所讨论的功能:
function read_rss($display=0,$url='') {
$doc = new DOMDocument();
$doc->load($url);
$itemArr = array();
foreach ($doc->getElementsByTagName('item') as $node) {
if ($display == 0) {
break;
}
$itemRSS = array(
'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
'description'=>$node->getElementsByTagName('description')->item(0)->nodeValue,
'link'=>$node->getElementsByTagName('link')->item(0)->nodeValue);
array_push($itemArr, $itemRSS);
$display--;
}
return $itemArr;
}
'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
这句话的意思是:
function read_rss($display=0,$url='') {
$doc = new DOMDocument();
$doc->load($url);
$itemArr = array();
foreach ($doc->getElementsByTagName('item') as $node) {
if ($display == 0) {
break;
}
$itemRSS = array(
'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
'description'=>$node->getElementsByTagName('description')->item(0)->nodeValue,
'link'=>$node->getElementsByTagName('link')->item(0)->nodeValue);
array_push($itemArr, $itemRSS);
$display--;
}
return $itemArr;
}
'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
在PHP4中不能这样做 我必须做一些类似的事情
$nodes = $node->getElementsByTagName('title');
$item = $nodes->item(0);
$value = $item->nodeValue,
尝试一下,它就会工作。PHP4不支持对象取消引用。所以
$obj->something()->something
将无法工作。您需要执行$tmp=$obj->something()$tmp->something
..在PHP4中不能链接对象调用。您必须分别调用一个变量并将其全部存储起来
$titleobj = $node->getElementsByTagName('title');
$itemobj = $titleobj->item(0);
$value = $itemobj->nodeValue;
...
'title'=>$value,
你必须在所有的连锁电话上这样做
至于.htaccess。。。您需要与控制实际服务器的人交谈。听起来好像.htaccess不允许更改您试图更改的设置。您需要将该行分解为单个变量。PHP4不喜欢->后面的括号。改为这样做:
$title = $node->getElementsByTagName('title');
$title = $title->item(0);
$description = $node->getElementsByTagName('description');
$description = $description->item(0);
$link = $node->getElementsByTagName('link');
$link = $link->item(0);
$itemRSS = array(
'title'=>$title->nodeValue,
'description'=>$description->nodeValue,
'link'=>$link->nodeValue);
每个变量的两个声明可能是冗余和压缩的,我不确定PHP4将如何响应。如果需要,您可以尝试压缩它们。DOMDocument是PHP5函数。您不能使用它。
您可能需要使用DOM XML(PHP4)函数请将两个问题分成两个问题。数据库中没有即将出现的短缺;)而且不太可能有人会同时回答你的两个问题。