View previous topic :: View next topic |
Author |
Message |
Vieri l33t
Joined: 18 Dec 2005 Posts: 887
|
Posted: Sun Dec 14, 2008 6:43 pm Post subject: [SOLVED] Php utf-8 bom |
|
|
Hi,
I 'm running PHP5 on Gentoo and would like to create a script which sends out text preceded by a BOM. I need this because a remote client program reads the BOM and the text after it.
So basically, I wrote something like:
Code: |
<?php
$BOM = "\xEF\xBB\xBF";
echo $BOM."OK";
?>
|
However, PHP doesn't like this and generates an error:
Quote: | Parse error: syntax error, unexpected T_VARIABLE |
Likewise, if I save a text file with BOM and then try to read it and send it out with PHP like this:
Code: |
<?php
readfile("bom.txt");
echo "OK";
?>
|
I get a PHP error:
Quote: | Parse error: syntax error, unexpected T_STRING |
I'd greatly appreciate it if someone could give me a clue as to what I'm doing wrong.
Thanks in advance.
Last edited by Vieri on Sun Dec 14, 2008 7:46 pm; edited 1 time in total |
|
Back to top |
|
|
amdg n00b
Joined: 27 Oct 2008 Posts: 45
|
Posted: Sun Dec 14, 2008 7:28 pm Post subject: |
|
|
The code snippets you posted work for me.
Since you're not posting your exact code and error messages/stack traces, it's going to be hard to help you. But the first thing you should do is to get your code to compile before blaming the BOM. Double-check the script for syntax errors. |
|
Back to top |
|
|
Vieri l33t
Joined: 18 Dec 2005 Posts: 887
|
Posted: Sun Dec 14, 2008 7:45 pm Post subject: |
|
|
amdg wrote: | Since you're not posting your exact code and error messages/stack traces. |
Thanks, I made an assumption I shouldn't have.
The code *was* like I posted it except for an include. That was the culprit. I still have to understand why, since the PHP include only has $VAR variables set.
Anyway, the BOM issue seems to be ok now so I'm closing this topic.
Thanks for your time. |
|
Back to top |
|
|
|