Many times I have used an css technique that I “learned” by myself. When I depends on a dynamic stylesheet that I can put it on html doc, I use css files that’s are not css in fact, they’re php files. Example: style.css.php. ALWAYS worked. But now I’m getting trouble with this in a strange behavior that I never saw before. My fundo.css.php file have this simple format:
body {
background: url(../arquivos/imagens/<?php
// some php functions..
echo "coyote.jpg";
?>) top left no-repeat;
}
It sends this response to the browser:
body {
background: url(../arquivos/imagens/coyote.jpg) top left no-repeat;
}
Beautiful but if browser show the background! On Firebug console (as on Dev Tools in Chrome) in Network tab the url that’s browser trying to find is:
http://localhost:8080/ultimocaso/arquivos/imagens/%EF%BB%BF%EF%BB%BF%EF%BB%BF%EF%BB%BF%EF%BB%BFcoyote.jpg
If I just use an css normal file with that content it works like a charm.
Anyone knows tell me why the hell is happening that and/or how to fix it?
EDIT
I’m usgin Adobe Dreamweaver to edit my files and in my Preferences -> New Document the option to include BOM signature is OFF !!
The problem is that you are including files that have a UTF-8 BOM within your PHP.
Although you cannot see this BOM (Byte Order Mark), you can imagine that the files are including in reality look like this:
When you use the
includefunction, you are effectively importing those characters into your file at the point where you included your code.Is actually interpreted something like:
One way to avoid the BOMs in the middle of your code is to make all includes somewhere where they will have less impact, such as at the beginning of your file. Another way (my personal choice) would be to save your imported files in a format that has no BOM, such as regular UTF-8.