Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Php utf-8 bom
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 887

PostPosted: Sun Dec 14, 2008 6:43 pm    Post subject: [SOLVED] Php utf-8 bom Reply with quote

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
View user's profile Send private message
amdg
n00b
n00b


Joined: 27 Oct 2008
Posts: 45

PostPosted: Sun Dec 14, 2008 7:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 887

PostPosted: Sun Dec 14, 2008 7:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum