Recently I faced with an abnormal thing in my website's RSS.
There is an extra space character in the begining of rss page source and browsers can't show it because of bellow error :
error on line 1 at column 6: XML declaration allowed only at the start of the document
My code is simple and im using in other websites without a problem
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
echo "<rss version=\"2.0\"
";
echo " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
";
echo " xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"
";
echo " xmlns:admin=\"http://webns.net/mvcb/\"
";
echo " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" >
";
echo "<channel>
";
echo "<title>".htmlspecialchars($sitename)."</title>
";
echo "<link>".htmlspecialchars($url)."</link>
";
echo "<description>".$slogan."</description>
";
echo "<dc:language>".$backend_language."</dc:language>
";
echo "<dc:creator>".$adminmail."</dc:creator>
";
echo "<dc:date>".$now."</dc:date>
";
echo "<sy:updatePeriod>hourly</sy:updatePeriod>
";
echo "<sy:updateFrequency>1</sy:updateFrequency>
";
echo "<sy:updateBase>".$now."</sy:updateBase>
";
and the outcome is this :
<?xml version="1.0" encoding="utf-8"?>
<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#">
<channel>
As you can see before
what should i do to solve this problem !?