Php &引用;RES";DOMDocument XML在服务器上不工作,在本地工作
此代码在本地工作,但不在服务器上工作 服务器php版本为5.4,本地php版本为5.3Php &引用;RES";DOMDocument XML在服务器上不工作,在本地工作,php,xml,domdocument,Php,Xml,Domdocument,此代码在本地工作,但不在服务器上工作 服务器php版本为5.4,本地php版本为5.3 <?php $rss = new DOMDocument(); $xml = file_get_contents('http://www.directe.cat/sindica.php?lloc=acn&comarca=Alt%20Urgell'); $rss->loadXML($xml); $feed = array(); foreach ($rs
<?php
$rss = new DOMDocument();
$xml = file_get_contents('http://www.directe.cat/sindica.php?lloc=acn&comarca=Alt%20Urgell');
$rss->loadXML($xml);
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 4;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['title'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<small><em>Escrit: '.$date.'</em></small></p>';
echo '<p>'.$description.'</p>';
}
?>
loadXML($xml);
$feed=array();
foreach($rss->getElementsByTagName('item')作为$node){
$item=数组(
'title'=>$node->getElementsByTagName('title')->项(0)->nodeValue,
'desc'=>$node->getElementsByTagName('description')->项(0)->节点值,
'link'=>$node->getElementsByTagName('link')->项(0)->nodeValue,
'date'=>$node->getElementsByTagName('pubDate')->项(0)->节点值,
);
阵列推送($feed,$item);
}
$limit=4;
对于($x=0;$x)
在.htaccess文件的下面一行添加此内容。这样它就可以工作了
php_值allow_url_fopen On检查服务器上的phpinfo(),并检查allow_url_fopen的ini值,该值必须等于On,才能使文件获取内容与http/https://uri一起工作。感谢这是解决方案