Re: PHP Includes (was BOM and UTF-8)

Michael Adams wrote:
> On Mon, 11 Dec 2006 14:51:00 +0000
> Richard Ishida wrote:
>> [2] there is now a series of 3 pages for investigating display issues
>> related to bom handling - a third test has been added to test PHP
>> includes(which seem to cause problems for IE and Opera).
> 
> I do not understand what the issue could be here. PHP should leave no
> artifacts or traces that should be visible to any browser. Could someone
> clarify please.

I believe the problem is that when you include a file using PHP, the 
file is included exactly as-is and if the included file begins with a 
BOM, that character will be included in the output wherever that file 
was included.

e.g.
([BOM] represents the Byte Order Mark)

a.php:

   [BOM]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
   <title>Testing</title>
   <?php include "b.php"?>


b.php:

   [BOM]<p>This is an included file


Output:

   [BOM]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
   <title>Testing</title>
   [BOM]<p>This is an included file

That can cause a problem because the BOM is an unexpected character.  In 
this case, it causes a character data is not allowed here error. 
Depending on where it was included, the extra character could cause 
other problems too.


-- 
Lachlan Hunt
http://lachy.id.au/

Received on Wednesday, 13 December 2006 07:33:27 UTC