note 82414 added to function.header

From: Date: Wed, 09 Apr 2008 22:46:54 +0000
Subject: note 82414 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-138083@lists.php.net to get a copy of this message
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. ---- Server IP: 208.69.120.35 Probable Submitter: 204.193.129.239 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/82414 Del: integrated -- https://master.php.net/note/delete/82414/integrated Del: useless -- https://master.php.net/note/delete/82414/useless Del: bad code -- https://master.php.net/note/delete/82414/bad+code Del: spam -- https://master.php.net/note/delete/82414/spam Del: non-english -- https://master.php.net/note/delete/82414/non-english Del: in docs -- https://master.php.net/note/delete/82414/in+docs Del: other reasons-- https://master.php.net/note/delete/82414 Reject -- https://master.php.net/note/reject/82414 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138083) next »