【发布时间】:2012-03-14 00:22:29
【问题描述】:
这段代码可以完美运行,没有任何变化,只是现在它正在发出错误。
function wrapOutput($str){
header('content-type: text/xml; charset: utf-8');
$o = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
$o .= ' <rss version="2.0"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:amp="http://www.adobe.com/amp/1.0">' . PHP_EOL;
$o .= ' <channel>' . PHP_EOL;
$o .= $str;
$o .= ' </channel>' . PHP_EOL;
$o .= ' </rss>' . PHP_EOL;
return $o;
}
出了点问题,把 xml 标签变成了<'xml version="1.0" encoding="UTF-8"'>
这会导致以下错误
XML Parsing Error: not well-formed
Location: http://localhost/mrss.php?feed=test
Line Number 1, Column 2:<'xml version="1.0" encoding="UTF-8"'>
-^
【问题讨论】: