occasional Posted April 15, 2008 Share Posted April 15, 2008 Php newbie here. I uploaded several proven .php scripts "as is" (i.e., I did not edit them at all) that were written by experienced PHP coders to my IIS server (php ver 5.2), and they correctly generated the HTML output that I expected. Next, using my desktop editor I changed one single harmless character in each of the two .php scripts and then uploaded both .php scripts, and now they continue to generate the same HTML output as before but, in both cases, the HTML outputted is now preceded by these three characters: "" (an upsidedown question mark and two other special symbols). How do I avoid these three characters from somehow being inserted into my output stream? I am guessing that my editor somehow inserts some non-visible character or characters that in turn causes PHP to generate these three mystery characters, but I have tried several common editors and the same thing happens. How do I get rid of them from my HTML output? TIA Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/ Share on other sites More sharing options...
soycharliente Posted April 15, 2008 Share Posted April 15, 2008 Generally I experience random characters when I use text editors that may save the text with a different encoding than previously used. Is there no blank space at the beginning of the script? Are there characters missing and you see these instead? Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517855 Share on other sites More sharing options...
effigy Posted April 15, 2008 Share Posted April 15, 2008 That's a UTF-8 BOM. Double check the character sets and/or encodings that your editor and server are using. Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517859 Share on other sites More sharing options...
conker87 Posted April 15, 2008 Share Posted April 15, 2008 You're not using the new FrontPage are you? That's what caused this to happen when I had it. I just used Notepad 2 after that. Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517863 Share on other sites More sharing options...
occasional Posted April 15, 2008 Author Share Posted April 15, 2008 I have tried Notepad, Microsoft Expression Web, Visual Studio...editors that I use for all other sites. It is only when I update .php files that this shows up. I know of no obviously missing characters. I have run into this in the past but never resolved it, and they have cropped up again. What I am doing is opening up the "vanilla" scripts, changing one single character in the middle of the .php file (something really harmless like changing a "4" to a "5") and then saving the .php file. Every time I update a working .php file the result is the same - regardless of the editor I use. Also, even if I create a single-statement .php file like the following: <?php echo 'Current PHP version: ' . phpversion(); ?> ...the resulting output stream is preceded by those same three characters, and looks like this: Current PHP version: 5.2.0 I use all the defaults for any editor I use, and the standard US keyboard and settings. Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517869 Share on other sites More sharing options...
effigy Posted April 15, 2008 Share Posted April 15, 2008 Do these show in the files themselves, or only after being filtered through PHP? It sounds like your editor is saving them as UTF-8. Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517885 Share on other sites More sharing options...
occasional Posted April 15, 2008 Author Share Posted April 15, 2008 Only after being filtered thru PHP. Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517886 Share on other sites More sharing options...
effigy Posted April 15, 2008 Share Posted April 15, 2008 Are you positive? The editor may hide the BOM's from you. Have you tried viewing them in notepad or a hex editor? Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517900 Share on other sites More sharing options...
occasional Posted April 15, 2008 Author Share Posted April 15, 2008 Solved (sort of). Your question prompted me to hand count the # of characters in my test .php file and compare it to the file size that shows up in my DIR listing: the DIR listing file size was always 3 bytes larger. Thus, even though my standard editors (notepad, Visual Studio, etc) continue to display only 53 characters in my sample one-line .php file as listed above, a DIR command would show 56 characters in that same file once I saved it. And if I saved it multiple times it would still contain 56 characters (i.e., my editors did not keep adding an additional 3 characters each time I saved the file) but a subsequent visual hand-count would still only show 53 characters. Note that I am using my 53-character sample one liner .php program in this example, but these mystery 3 characters are being inserted EVERY time I save a .php file. In fact, perhaps they are inserted for ALL files that I save and not just .php files, and it may be that only the PHP interpreter spits them out as " ". I don't have an explanation why the characters are being inserted and yet are not showing up in my various editors. I had to download another notepad replacement (Edit2 from download.com) and simply open up the .php file (which also showed only 53 characters) and then simply save it, and magically the DIR command would now show 53 characters. Thanks for at least helping me find a work-around. Link to comment https://forums.phpfreaks.com/topic/101237-%C3%AF%C2%BB%C2%BF/#findComment-517932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.