By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 814 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

include generates unexpected control character

P: n/a
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:
<ul>
<?php include('Menu/Association.inc'); ?>
</ul>
The file Menu/Association.inc starts with:
<li><a href="Association.php">Strona Stowarzyszenia</a></li>
(I mean before <lithere 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 <uland <li- 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/
Dec 6 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Thu, 06 Dec 2007 07:35:01 +0100, R.A.M. <r_********@poczta.onet.pl
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:
<ul>
<?php include('Menu/Association.inc'); ?>
</ul>
The file Menu/Association.inc starts with:
<li><a href="Association.php">Strona Stowarzyszenia</a></li>
(I mean before <lithere 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 <uland <li- 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?
UTF-8 BOM that shouldn't be there? (EF BB BF)
--
Rik Wasmus
Dec 6 '07 #2

P: n/a
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:
<ul>
<?php include('Menu/Association.inc'); ?>
</ul>
The file Menu/Association.inc starts with:
<li><a href="Association.php">Strona Stowarzyszenia</a></li>
(I mean before <lithere 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 <uland <li- 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 <ul>
from the <?php by exactly that much?

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
Dec 6 '07 #3

P: n/a
Thanks.
I have checked the output using your program. It contains three additional
(not occuring in .php nor .inc) bytes (just before "<li>") with decimal
values: 239 187 191 (printable, non-English letters). Where are they from in
output? How to get rid of them?
/RAM/
Dec 6 '07 #4

P: n/a
Użytkownik "R.A.M." <r_********@poczta.onet.plnapisał w wiadomo¶ci
news:fj**********@news2.task.gda.pl...
It contains three additional (not occuring in .php nor .inc) bytes (just
before "<li>") with decimal values: 239 187 191 (printable, non-English
letters).
The sequence starts a place of usage of every <?php include... ?(a few
times in my .php file), as well as before initial <!DOCTYPE at the beginning
of output (three first bytes of output).
/RAM/
Dec 6 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.