http://seosailor.com/beta2/articles/showrss此网址在 chrome 上出现错误 Extra content at the end of the document
我的代码是这样的
function showrss() {
header("Content-Type: application/xml; charset=ISO-8859-1");
$query_items = "select * from articles";
$result_items = mysql_query ($query_items) or die("Some error: ".mysql_error());
$xml = '<?xml version="1.0" encoding="ISO-8859-1" ?><rss version="2.0"><channel>';
while($row = mysql_fetch_array($result_items))
{
//$des = mysql_real_escape_string($row['a_description']);
// $a_des = str_replace(']]>', ']]>',$row['a_description']);
//$a_des = strip_tags($row['a_description']);
// $a_des = preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags($row['a_description']));
$a_des = htmlspecialchars($row['a_description']);
$xml .= '<item>
<title>'.$row["a_title"].'</title>
<link>'.$row["a_url"].'</link>
<description>'.$a_des.'</description></item>';
} $xml .= '</channel>';
$xml .= '</rss></xml>';
echo $xml;}
最佳答案
那是因为额外的</xml>
结束标记位于末尾(没有开始 <xml>
标记)。
关于php - Chrome 上文档末尾的额外内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18766642/