嗨,我使用此代码调用 RSS xml 文件中的最后一个条目,它在本地和其他服务器中运行良好,所以我猜是allow_url_fopen=on;
,但即使我设置了这个,我也没有得到答案,我不回显任何 rss 提要,问题是代码没问题,在 localhost 中工作正常
我该如何解决这个问题,我启用什么参数或如何在 php.ini
代码
<?php
$rss = new DOMDocument();
$rss->load('http://www.laesquinadelamoda.com/feed/');
$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 = 1;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$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>Posted on '.$date.'</em></small></p>';
//echo '<p>'.$description.'</p>';
echo '"'.$title.'" - <span class="ital"><i><a href="'.$link.'" title="'.$title.'">Ver</a></i></span>';
}
?>
php.ini
; As of 4.0b4, PHP always outputs a character encoding by default in
; the Content-type: header. To disable sending of the charset, simply
; set it to be empty.
;
; PHP's built-in default is text/html
default_mimetype = "text/html"
;default_charset = "utf-8"
allow_url_fopen=on;