我已经创建了一个rss feed,所有东西都能很好地工作,但是在这个xml代码中
<description><![CDATA[****no php is allowed here****]]></description>
这是我生成xml文件的视图
<?php
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><?php echo $feed_name; ?></title>
<link><?php echo $feed_url; ?></link>
<description><?php echo $page_description; ?></description>
<dc:language><?php echo $page_language; ?></dc:language>
<dc:creator><?php echo $creator_email; ?></dc:creator>
<dc:rights>Copyright <?php echo gmdate("Y", time()); ?></dc:rights>
<admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
<?php foreach($posts as $entry): ?>
<item>
<title><?php echo $entry->title_nw; ?></title>
<link><?php echo site_url('view=entry'.'&'.'id=' . $entry->id_nw); ?></link>
<guid><?php echo site_url('blog/post/' . $entry->url_title); ?></guid>
<description><![CDATA[
<?php character_limiter($entry->text_nw, 200); ?>
]]></description>
<pubDate><?php echo $entry->date_nw;?></pubDate>
</item>
<?php endforeach; ?>
</channel></rss>
请向下滚动,您可以看到此代码
<description><![CDATA[
<?php character_limiter($entry->text_nw, 200); ?>
]]></description>
这是代码在描述标签
中不可接受的问题答案 0 :(得分:1)
IIRC character_limiter()不回显结果,只返回它们。所以:
1)确保在调用该函数之前已在控制器中加载了文本助手 2)尝试:
<description><?php echo htmlspecialchars(character_limiter($entry->text_nw, 200)); ?></description>