pwired Posted April 8, 2014 Share Posted April 8, 2014 Hi, I´m developing local on a wamp but can´t get it to work and I suspect some character could be the cause. I have a simple template file: <?php /** * Page template * */ include("./head.inc"); include("./main.inc"); include("./foot.inc"); When I want to view a page in firefox it doesn´t show the page how it should look like but shows all the html code. Also I see these strange characters: (black square with question mark) This is part of a page showing in firefox: ��<body> <div id="topbar"> </div> ��<div id="footer"> What I also notice is that these strange characters appear just before an include. Notice that 2 of these characters show up just before main.inc is included that starts with this code <body> <div id="topbar"> Again 2 of these characters show up just before foot.inc is included that starts with this code <div id="footer"> I tried to trace back these characters but failed. I opened main and foot.inc with notepad which should show these characters but they are not there in notepad. I always thought that notepad does not suffer from hidden characters. Do you think that these characters are the cause of my pages not showing up as they should in firefox but instead show all html ? Link to comment Share on other sites More sharing options...
netcarver Posted April 8, 2014 Share Posted April 8, 2014 Don't use notepad: please!. AFAIR it doesn't handle utf8 and byte order marks correctly. Those characters are probably BOMs from the start of the included files. Try to use an editor that allows you to set the encoding and line ending of your files. You wan't to set the encoding to "UTF-8 without BOM" and use linux line endings where possible. When I last used Windows (about 10 years ago now) I was using Notepad++ which did the job really well. There are other options on windows - try googling for "programmers editors windows" or something like that. Once you have a good editor, set it up to save using UTF-8 no BOM and re-save all your files from it. I'm guessing that will solve your issue but cannot guarantee it. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted April 8, 2014 Share Posted April 8, 2014 Do you think that these characters are the cause of my pages not showing up as they should in firefox but instead show all html ? yep 1 Link to comment Share on other sites More sharing options...
netcarver Posted April 8, 2014 Share Posted April 8, 2014 @pwired If you are learning about programming/developing then do invest time in learning some quality tools as you'll use then a LOT. Getting a good development toolchain and workflow setup will repay you many times the investment you put in up front. One thing you don't wan't to screw around with is a sub-par editor like notepad that doesn't even let you chose the character set to save a file in especially if you are pasting in snippets from all over the internet with diverse character encodings. You will waste your time and ours if you continue down that road. Do yourself a favour and learn something powerful like vim, textmate, sublimetext2 or one of the better IDE editors. 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted April 8, 2014 Share Posted April 8, 2014 <quote>pasting in snippets from all over the internet</qoute>, makes good gremlins. 1 Link to comment Share on other sites More sharing options...
pwired Posted April 9, 2014 Author Share Posted April 9, 2014 Ok guys, thanks for the replies. I solved the problem by opening head.inc, main.inc and foot.inc again in notepad and then saved again but this time with the option encoding Ansi. The strange characters �� disappeared and the website shows up how it should be in firefox. So both Netcarver and Martijn had it right. Actually I remember now that I had once the exact same problem back in the days with Evo. Do yourself a favour and learn something powerful like vim, textmate, sublimetext2 or one of the better IDE editors. Do these editors you mention show hidden characters (if any) when you paste code in them ? Notepad didn´t show them while they were there. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted April 9, 2014 Share Posted April 9, 2014 Do invisible character mess up your webpage? 2 Link to comment Share on other sites More sharing options...
netcarver Posted April 9, 2014 Share Posted April 9, 2014 @pwired, I'm glad you got your issue sorted out! It seems I may be wrong about notepad if it does let you choose the encoding - apologies for that - perhaps it has been improved in the last 10 years. Switching to Ansii definitely kills the BOM but it will limit your ability to use UTF-8 characters in your PHP even if you don't use them directly in the HTML. So I'd still recommend using a fully fledged programming editor over notepad. Personally, I use vim as my editor and you can set it up to show "whitespace" characters. It does have a long and steep learning curve though so you might be better served by notepad++ or Sublimetext2. I've not had any trouble with BOMs since I stopped using Windows and switched to Linux & vim as my editor. If your webserver and HTML headers are serving your pages as UTF-8 then sending only Ascii chars will be fine (they are a subset of UTF-8) but pretty limiting, especially if you ever need to use a language other than English at any point. UTF-8 without BOM does seem the way to go for webpages (at least at the moment.) Link to comment Share on other sites More sharing options...
pwired Posted April 9, 2014 Author Share Posted April 9, 2014 Personally, I use vim as my editor and you can set it up to show "whitespace" characters. @ Netcarver, thanks for mentioning that. I personally like it when an editor shows those "characters" while editing. I also like this pdf found on the vim page because I am on win7 http://www.vim.org/ugrankar.pdf Link to comment Share on other sites More sharing options...
Joss Posted April 9, 2014 Share Posted April 9, 2014 Yes, MS Notepad changed many years ago now. However, although I use Sublime mostly now, I still find myself falling back to TextPad and Notepad++ regularly. Very fond of TextPad, to be honest, though it has never been very popular, probably because it is not strictly free, though you can evaluate it forever. I always liked its robust search within files Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now