note 71662 added to function.header

From: Date: Sun, 10 Dec 2006 16:26:32 +0000
Subject: note 71662 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-120487@lists.php.net to get a copy of this message
We're building an application that parses the URL and responds according to the structure contained there (similar to the way WordPress does it). The problem we ran into was that in spite of having the correct charset (ISO-8859-1) in the database and set in the HTML meta tags, the browser was still rendering the pages in UTF-8 encoding (which seems to be the default on the server). Using AddCharset in .htaccess didn't work, since that only applies to certain file extensions and was useless given our "domain.com/directory/directory/" URL style (that is, no file extensions appear in the URL, so the charset in .htaccess seems to be ignored). After searching high and low on the Web for a solution, the only thing we found that worked was using the following to force the Content-Type for displaying the pages our application generates: <?php header('Content-Type: text/html; charset=ISO-8859-1'); ?> This is sent to the browser before any content is output. Now all the accents on the page display correctly and the proper charset information is sent to the browser. Hopefully this will save someone else some head-scratching! If anyone knows of a better way to handle this issue (we've tried everything we came across so far), please let me know. ---- Server IP: 203.202.10.60 Probable Submitter: 203.112.73.207 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/71662 Del: integrated -- https://master.php.net/note/delete/71662/integrated Del: useless -- https://master.php.net/note/delete/71662/useless Del: bad code -- https://master.php.net/note/delete/71662/bad+code Del: spam -- https://master.php.net/note/delete/71662/spam Del: non-english -- https://master.php.net/note/delete/71662/non-english Del: in docs -- https://master.php.net/note/delete/71662/in+docs Del: other reasons-- https://master.php.net/note/delete/71662 Reject -- https://master.php.net/note/reject/71662 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120487) next »