Page 1 of 1

php causes trash hex 3f

Posted: Fri Feb 20, 2009 12:15 am
by estarapapax
if for example i have this code:

Code: Select all

<?php
$a = 1;
require('something.php');
require('something2.php');
?>
<html>
<body>
<p>aaaaaa
<?php echo '<br/>'.$a;  ?>
<br/>
<p>aaaaaa
</body>
</html>
Assuming there is only one '<?php' per included (require) php file, then the output HTML will have produce three hex 3F before the <html> tag and one hex 3F before the first <br/> tag. I googled and fund out that each call to '<?php' causes a single hex 3F. And the problem now is that, even though most of these trash characters are outside the <html> tag, they are still displayed in web browsers. Is there a solution to avoid this. I'm using PHP 5.2.8 and I'm running it in my laptop using xampp.

Re: php causes trash hex 3f

Posted: Fri Feb 20, 2009 12:25 am
by Benjamin
What in the world are you talking about? Opening PHP tags do not send any output to the browser.

Re: php causes trash hex 3f

Posted: Fri Feb 20, 2009 12:39 am
by estarapapax
Ok.. I made a simple example

This is the content of test.php

Code: Select all

<?php
 
$a = 'aaaaaa';
$b = 'bbbbbb';
 
    for($i = 0; $i < 100; $i ++)
        require('test2.php');
 
?>
<html>
<body>
<?php
    echo $a.$b;
?>
</body>
</html>
and this is the content of test2.php

Code: Select all

<?php
    $justanything = 'justanything';
?>
Here is the link you can click
http://yonips.110mb.com/aaaa/test.php

press ctrl+a once the page finished loading. copy it and paste it in notepad. you'll see 100 square trash characters. if you paste that to a hex editor, those are 3f.

Also, you can view the source of the page and you'll see the same if you paste that source to notepad.

Don't say that it doesn't affect the page. It does. Just observe the linked page carefully. The text is offset a little from the left side. On the website I'm creating, those trash characters makes there own block, not allowing me to create a div block with the contents I want at the very top of the page.

EDIT: I just found out what's casing it. I encoded the my PHP files using utf-8. If they're in ANSI, there won't be any problem. Oh well.

Re: php causes trash hex 3f

Posted: Fri Feb 20, 2009 4:02 am
by Chris Corbyn
Sounds like your UTF-8 files include the BOM.