note 82414 deleted from function.header by danbrown
| From: | danbrown@php.net | Date: | Sun, 07 Dec 2008 18:01:24 +0000 |
| Subject: | note 82414 deleted from function.header by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147797@lists.php.net to get a copy of this message | ||
Note Submitter: Alex J. Fierro
----
As stated above, the header is important when using PHP code to generate XML sitemaps.
To make the sitemap, I started by adding...
AddType application/x-httpd-php .xml
to the root .htaccess file so I could run PHP in my XML files.
I then created "sitemap.xml" and wrote the code to dynamically write the sitemap.
However, when I set the XML header, I was the getting "headers already sent" error.
After toying for awhile, I solved the issue.
Although XML sitemaps should be encoded in UTF-8, the PHP was giving me header errors unless I
encoded the XML file in ANSI.
So, I encoded the XML file in ANSI and set the header as...
header('Content-type: application/xml; charset="utf-8"',true);
...and it solved the issue. My sitemap now works and passes verification. Hopefully, I'm not
making a mistake in encoding and this tip helps someone.