开发者

XHTML validation: character "" not allowed in prolog. Why?

开发者 https://www.devze.com 2023-04-12 18:54 出处:网络
Why doesn\'t this page validate? http://www.jethroweb.nl/test/test.php I think the XHTML code is okay, but the W3C Markup Validation Service and the WDG HTML Validator do not agree.

Why doesn't this page validate?

http://www.jethroweb.nl/test/test.php

I think the XHTML code is okay, but the W3C Markup Validation Service and the WDG HTML Validator do not agree.

UPDATE: The XHTML code is generated by PHP, this are the first lines of code:

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"';
echo PHP_E开发者_开发问答OL;
echo '        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
echo PHP_EOL;
echo '<html xmlns="http://www.w3.org/1999/xhtml">';
echo PHP_EOL;
echo '<head>';
echo PHP_EOL;

UPDATE2: Maybe it's more a PHP question. When I paste the generated XHTML code into Notepad++ I see a question mark at the first row:

XHTML validation: character "" not allowed in prolog. Why?


As per the W3C validator

Byte-Order Mark found in UTF-8 File.

The Unicode Byte-Order Mark (BOM) in UTF-8 encoded files is known to cause problems for some text editors and older browsers. You may want to consider avoiding its use until it is better supported.

That's the reason for your error: the byte order mark is a zero-width space, and it's telling you that character isn't allowed in the prolog (before the doctype).

Re-save the file with a text editor that allows saving without a BOM (virtually everything except Notepad).


Because the file is sent with a byte order mark.

The byte order mark is used to identify the encoding for text files, but they should not be included when you send the text over the web.

If your web server can't remove the byte oder mark when it sends the file, you have to save the file without the byte order mark. Most editors have the option to do so in their Save As dialog.


Your php source file test.php contains the byte order mark. Try to save test.php again without byte order mark.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号