Hi,
I have a PHP file which outputs javascript code. It works well in
Firefox, but Opera chokes on it.
The problem is the PHP file contains UTF characters, so when I output
javascript code with PHP echo, then PHP prepends the output with an
UTF BOM:
var data = <? echo "[...]" ?>;
results in
var data = <BOM>[...];
Opera doesn't like the BOM within javascript code, it indicates a
syntax error. I cannot save the PHP file as non-UTF, because other
parts of it have UTF characters.
Is there a workaround for this? Is there a way to prevent echo from
outputting a BOM when the page itself is UTF?
I have a PHP file which outputs javascript code. It works well in
Firefox, but Opera chokes on it.
The problem is the PHP file contains UTF characters, so when I output
javascript code with PHP echo, then PHP prepends the output with an
UTF BOM:
var data = <? echo "[...]" ?>;
results in
var data = <BOM>[...];
Opera doesn't like the BOM within javascript code, it indicates a
syntax error. I cannot save the PHP file as non-UTF, because other
parts of it have UTF characters.
Is there a workaround for this? Is there a way to prevent echo from
outputting a BOM when the page itself is UTF?
Comment