...

View Full Version : header or meta for UTF-8?



low tech
01-16-2012, 07:12 AM
Hello all

I have changed my site to php pages so I can use php to include header file

but now I'm unsure if I should be using a header or meta tag to indicate the charset

ie which one of these is correct? Should I use a header and a meta tag?

At the moment i'm using version 2 which seems to be ok.

There is no other php involved other than the 'include' at the moment.


1)

<?php
header('Content-Type: text/html; charset=UTF-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!-- Leave this out <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > -->

</head>
<body>
<?php include_once ('includes/header.php') ?>

OR

2)

<?php

// header('Content-Type: text/html; charset=UTF-8'); //Leave this out

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >

</head>
<body>
<?php include_once ('includes/header.php') ?>

help very much appreciated

LT

12k
01-16-2012, 07:43 AM
Either one should work fine. It just tells the browser how to read the text.

felgall
01-16-2012, 08:40 PM
Any meta http-equiv is just an attempt to apply the header info after the page has started to load. Sometimes this is allowed and sometimes it isn't. Where you have access to set the http header directly there is no reason why you should use http-equiv to try to set it later than where it is supposed to be set.

low tech
01-17-2012, 12:10 AM
Hi felgal


Any meta http-equiv is just an attempt to apply the header info after the page has started to load. Sometimes this is allowed and sometimes it isn't. Where you have access to set the http header directly there is no reason why you should use http-equiv to try to set it later than where it is supposed to be set.


That makes sense ---- so method 1 -- use php header


Thanks

LT



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum