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.

([BOM] represents the Byte Order Mark)


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


   [BOM]<p>This is an included file


   [BOM]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
   [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
Received on Wednesday, 13 December 2006 07:33:27 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:17:50 UTC