CreepinJesus Posted December 16, 2007 Share Posted December 16, 2007 I'm new to PHP; so, if you reply, could you be fairly explanatory, please I have a basic page that has two includes. The included files are .htm files (basically a header and footer for the page). However, in their positions, the page displays  a line above the include. What is this? Does it mean something's messed up? Quote Link to comment Share on other sites More sharing options...
corbin Posted December 16, 2007 Share Posted December 16, 2007 What's the character encoding on all of the files, and what kind of characters are in them? Quote Link to comment Share on other sites More sharing options...
CreepinJesus Posted December 16, 2007 Author Share Posted December 16, 2007 Character set is ISO-8859-1, and I guess the encoding is whatever the defualt is (not sure where to find it). Quote Link to comment Share on other sites More sharing options...
corbin Posted December 16, 2007 Share Posted December 16, 2007 I've had weird problems with PHP files that are encoded in UTF-8 or Unicode, so that might be it.... Try using ANSII as the encoding, and see if the weird chars go away. Actually, I don't remember which char set the one you said is.... Hmmmm lol.... Anyway, to change/see the encoding, open it in notepad, go to save as, and look at the encoding. Quote Link to comment Share on other sites More sharing options...
CreepinJesus Posted December 16, 2007 Author Share Posted December 16, 2007 Yep it was in UTF-8. I've re-saved it as ANSI and... *checks* Bingo. That did the job. Thanks. Quote Link to comment Share on other sites More sharing options...
corbin Posted December 16, 2007 Share Posted December 16, 2007 Ahhh I ran into that problem the other day when I was trying to get some Russian/Korean/Chinese to show up in PHP files.... Seems PHP only likes ANSII x.x. Quote Link to comment Share on other sites More sharing options...
haku Posted December 16, 2007 Share Posted December 16, 2007 Actually php has the ability to handle non-latin characters, but its not easy, and involves enabling the double byte character library using your php.ini file, and then setting the settings a proper way. I have never done it with Chinese or Russian, but I currently program sites in Japanese and have had to do it for Japanese character encoding. Its not easy by any means, but it can be done. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted December 16, 2007 Share Posted December 16, 2007 Do you guys know what you're talking about? His problem is caused because of the BOM (Byte Order Mark). When saving a file in UTF-8 encoding, the BOM is automatically added at the start of the file. And then if the encoding is set wrong somewhere, the BOM will display. From Wikipedia: The UTF-8 representation of the BOM is the byte sequence EF BB BF, which appears as the ISO-8859-1 characters "" in most text editors and web browsers not prepared to handle UTF-8. And for all I know, it's perfectly cool to serve odd characters (that is non ISO-8859-1) with PHP, as long as you remember to tell both the actual file AND the browser (via (X)HTML) that the encoding should be UTF-8. And it is really recommended to use UTF-8 as encoding these days. I use the open-source text editor Notepad++ for all my writing/editing of files, and in that program you can choose to save your file as UTF-8 WITHOUT the annoying (and unnecessary) BOM. So my advice to everyone actually, is to use UTF-8 as encoding (without the BOM) and remember to: Save your file as UTF-8 (remember to choose this encoding from the start, otherwise look into converting from ISO-8859-1 to UTF-. Specify the encoding in your (X)HTML file, with the right meta tag: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> That way everything should work as intended Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.