What the hell is going on here? (php/or some crazy server issue...)

Associate
Joined
27 Oct 2002
Posts
897
Here is the source for "classroom.php"

Code:
<html>
<head>
  <meta http-equiv="content-type" content="application/xhtml+xml; charset=ISO-8859-1" />  
</head>
</html>

Pretty standard yes...?

The source of the page (www.altuseducation.co.uk/classroom.php) gives this

Code:
<html>
<head>
  <meta http-equiv="content-type" content="application/xhtml+xml; charset=ISO-8859-1" />  
</head>
</html>

The other pages in the same dir include the head of the file as far as the open body tag and produce this code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <title>Altus Eduction - Education by Innovation</title>
  <meta http-equiv="content-type" content="application/xhtml+xml; charset=ISO-8859-1" />
  <link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
... and so on ...

The first code originally said EXACTLY the same but I took out bits until I i was only left with that one meta tag.

I thought perhaps something was going wrong with php when it didn't actually have any php in the file so I put <?php echo("wtf");?> right at the beginning which wrote wtf after the .

If I remove the meta tag the  goes but how on earth can two almost identical pages behave differently?


Any idea what might be wrong with it?

Thanks
 
I'll take a wild guess that you edited and saved the problematic markup in Notepad?

Your problem is that you've authored and saved your file as UTF-8, but you're serving it from the webserver as ISO-8859-1 encoded text. The odd-looking set of symbols is the BOM (Byte Order Mark) used to indicate what sort of unicode encoding is being used. It's not needed for UTF-8, but Notepad decides to insert it regardless, without option to omit it. If you're not a Notepadder then check your editor's docs for modifying the working character encoding.

To fix this, you need to ensure your pages are being sent as UTF-8, not ISO-8859-1. Change the <meta> value's charset to UTF-8, and make sure the server's sending the charset as UTF-8 in the HTTP header (via header()/htaccess/httpd.conf). You can instantly see the problem by switching your browsers encoding to UTF-8 - View>Character Encoding... - and it will disappear.

Alternatively, save the file as ISO-8859-1, not UTF-8.

If you're going to be sticking in <meta> tags concerning character-encoding, you should really be aware of what character encoding you're using in your editor :).

/and incidentally, those files are being sent as text/html.
 
Last edited:
I'm using UltraEdit but I copied the header out of firefox's view source window which I guess might not be the right encoding.

That's a bugger, I spent ages on that thinking I'd gone crazy and it's something that simple!

And regarding the application/xhtml+xml bit, I'm not sure where that came from originally, it's been in my template header for years and I've never questioned it... must have cut and pasted it from somewhere when I wrote the header when I first started php :p

There is something a bit funky going on with MIME types on my server atm - I set up .application so that click once would work but the server started sending it as xml. When I overrode it with .htaccess it worked fine.

Would a server usually be set up to send .php responses as one specific type rather than allowing it to be set by a meta tag? I could change it with .htaccess but whatever I change it to might be wrong for certain pages so I'd rather it be settable by the page... I could do it in the header file using header() but I'd like to know for future reference anyway ;)

Thanks
 
The server may be configured to send a default character set in the header for any files that are text/plain or text/html (that includes .php files outputting HTML). This is done with the directive:
Code:
AddDefaultCharset
http://httpd.apache.org/docs/2.0/mod/core.html#adddefaultcharset

You can override the default in an .htaccess:
Code:
AddDefaultCharset ISO-8859-1
or
AddDefaultCharset Off

<meta http-equiv=""> tags are always overriden by the equivalent setting in the HTTP header. <meta>'s really a fallback mechanism - say if you wanted to play a website from a CD-ROM, you can keep the MIME and encoding information intact by passing it in the <meta> tag.

I'm not sure what ".application" or "click once" is, but you can configure the way files with different extensions are sent using the AddCharset and AddEncoding directives in your httpd.conf or .htaccess:
http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addcharset
 
Oh, .NET click once deployment. It packages up your application ready to be uploaded to a webserver. It automatically handles updates and required component installation. It's not bad but it's clearly only designed to work with windows pc's & ie and hosted on iis which is a shame since my server is nix and several of my target audience use firefox or opera :(


Thanks for the info, i'll try and get everything set up correctly in .htaccess since the util in cpanel doesn't appear to have any effect...
 
Back
Top Bottom