include generates unexpected control character
include generates unexpected control character
am 06.12.2007 07:35:01 von r_ahimsa_m
Hello,
I have little experience in PHP so I would like to ask a question. I use
PHP5 in Windows XP Professional, Apache 2.0.59.
I have created a website with index.php file. This file contains:
The file Menu/Association.inc starts with:
(I mean before there are no characters, "<" is first byte of the file).
Unexpectedly in a browser I noticed additional space. When I view source I
see in Notepad strange character between and - - Notepad shows it as
square box so I guess that it is a control character, ASCII < "!".
I tried to use readfile() instead of include() but with the same result.
Both files, index.php and Menu/Association.inc, are encoded using UTF-8 (I
have veryfied).
Could you help me please?
***Thanks***
/RAM/
Re: include generates unexpected control character
am 06.12.2007 07:50:29 von luiheidsgoeroe
On Thu, 06 Dec 2007 07:35:01 +0100, R.A.M. =
wrote:
> Hello,
> I have little experience in PHP so I would like to ask a question. I u=
se
> PHP5 in Windows XP Professional, Apache 2.0.59.
> I have created a website with index.php file. This file contains:
>
> The file Menu/Association.inc starts with:
>
> (I mean before there are no characters, "<" is first byte of the =
=
> file).
> Unexpectedly in a browser I noticed additional space. When I view sour=
ce =
> I
> see in Notepad strange character between and - - Notepad shows=
=
> it as
> square box so I guess that it is a control character, ASCII < "!".
> I tried to use readfile() instead of include() but with the same resul=
t.
> Both files, index.php and Menu/Association.inc, are encoded using UTF-=
8 =
> (I
> have veryfied).
> Could you help me please?
UTF-8 BOM that shouldn't be there? (EF BB BF)
-- =
Rik Wasmus
Re: include generates unexpected control character
am 06.12.2007 12:21:24 von Csaba2000
R.A.M. wrote:
> Hello,
> I have little experience in PHP so I would like to ask a question. I use
> PHP5 in Windows XP Professional, Apache 2.0.59.
> I have created a website with index.php file. This file contains:
>
> The file Menu/Association.inc starts with:
>
> (I mean before there are no characters, "<" is first byte of the file).
> Unexpectedly in a browser I noticed additional space. When I view source I
> see in Notepad strange character between and - - Notepad shows it as
> square box so I guess that it is a control character, ASCII < "!".
> I tried to use readfile() instead of include() but with the same result.
> Both files, index.php and Menu/Association.inc, are encoded using UTF-8 (I
> have veryfied).
Are you talking, perhaps, about the newline followed by
3 spaces that you yourself have inserted by separating the
from the
Double check by looking at the hex values (with php, of course!)
$text = file_get_contents("pathToFileGoesHere");
$max = strlen($text); // or put in your own maximum
for ($i=0;$i<$max;++$i) {
// Now show the bytes or their ascii codes
$ord = ord($chr=$text[$i]);
if ($chr>="A" && $chr<="Z") $ord = $chr;
else if ($chr>="a" && $chr<="z") $ord = $chr;
else if ($ord==32) $ord = "space";
print "$ord "; }
Csaba Gabor from Vienna
Re: include generates unexpected control character
am 06.12.2007 20:19:01 von r_ahimsa_m
Thanks.
I have checked the output using your program. It contains three additional
(not occuring in .php nor .inc) bytes (just before "
") with decimal
values: 239 187 191 (printable, non-English letters). Where are they from in
output? How to get rid of them?
/RAM/
Re: include generates unexpected control character
am 06.12.2007 20:23:32 von r_ahimsa_m
U¿ytkownik "R.A.M." napisa³ w wiadomo¶ci
news:fj9hv9$n9q$1@news2.task.gda.pl...
> It contains three additional (not occuring in .php nor .inc) bytes (just
> before "") with decimal values: 239 187 191 (printable, non-English
> letters).
The sequence starts a place of usage of every (a few
times in my .php file), as well as before initial
of output (three first bytes of output).
/RAM/
Re: include generates unexpected control character
am 06.12.2007 20:28:08 von luiheidsgoeroe
On Thu, 06 Dec 2007 20:19:01 +0100, R.A.M. =
wrote:
> Thanks.
> I have checked the output using your program. It contains three =
> additional
> (not occuring in .php nor .inc) bytes (just before "") with decima=
l
> values: 239 187 191 (printable, non-English letters). Where are they =
> from in
> output? How to get rid of them?
As I allready stated in my previous post:
239 187 191 =3D EF BB BF =3D UTF 8 BOM
http://en.wikipedia.org/wiki/Byte_Order_Mark
Teach your favourite editor not to put BOM's in UTF-8 files, they are no=
t =
needed. And indeed, any descent editor will not show these bytes as =
content of a file normally.
-- =
Rik Wasmus