W3C home > Mailing lists > Public > www-validator@w3.org > December 2006

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

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Wed, 13 Dec 2006 18:32:57 +1100
Message-ID: <457FACA9.7070009@lachy.id.au>
To: www-validator@w3.org

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:23 GMT