BOM a veces se encuentra dentro del texto, no al principio - si un archivo ha sido ensamblado alguna vez por php desde otros archivos usando por ejemplo include_once(). Para eliminarlo, elimine el área entre al menos un carácter antes de la BOM y al menos un carácter después de la BOM (por si acaso). La posición de BOM se puede ubicar en F12 Developer Tools de Internet Explorer y probablemente Edge. Se visualiza como rombo/rombo negro.
Visual Studio y WebMatrix pueden guardar archivos con o sin firma (al principio).
BOM provoca errores durante la validación (https://validator.w3.org/#validate_by_upload) o en consolas - </HEAD> pueden ser tratados como elemento huérfanos sin < HEAD>, al parecer, está presente:
Error: Stray end tag head.
< BODY> como segunda! < BODY>, cuando sólo uno < BODY> existe y todo es correcto:
Error: Start tag body seen but an element of the same type was already open.
y todo el documento se puede ver que carece de DOCTYPE, cuando BOM BOM o dos S ocupan la primera línea y DOCTYPE está en segunda línea, con un mensaje similar a este:
Error: Non-space characters found without seeing a doctype first. Expected e.g. <!DOCTYPE html>.
Error: Element head is missing a required instance of child element title.
Error: Stray doctype.
Error: Stray start tag html.
Error: Stray start tag head.
Error: Attribute name not allowed on element meta at this point.
Error: Element meta is missing one or more of the following attributes: itemprop, property.
Error: Attribute http-equiv not allowed on element meta at this point.
Error: Element meta is missing one or more of the following attributes: itemprop, property.
Error: Attribute name not allowed on element meta at this point.
Error: Element meta is missing one or more of the following attributes: itemprop, property.
Error: Element link is missing required attribute property.
Error: Attribute name not allowed on element meta at this point.
Error: Element meta is missing one or more of the following attributes: itemprop, property.
Error: Attribute name not allowed on element meta at this point.
Error: Element meta is missing one or more of the following attributes: itemprop, property.
Error: Attribute name not allowed on element meta at this point.
Error: Element meta is missing one or more of the following attributes: itemprop, property.
Error: Element title not allowed as child of element body in this context. (Suppressing further errors from this subtree.)
Error: Element style not allowed as child of element body in this context. (Suppressing further errors from this subtree.)
Error: Stray end tag head.
Error: Start tag body seen but an element of the same type was already open.
Fatal Error: Cannot recover after last error. Any further errors will be ignored.
(https://validator.w3.org/#validate_by_uri)
Y flujo de mensajes en IE consola F12 Herramientas de Desarrollo:
HTML1527: DOCTYPE expected. Consider adding a valid HTML5 doctype: "<!DOCTYPE html>".
HTML1502: Unexpected DOCTYPE. Only one DOCTYPE is allowed and it must occur before any elements.
HTML1513: Extra "<html>" tag found. Only one "<html>" tag should exist per document.
HTML1503: Unexpected start tag. HTML1512: Unmatched end tag.
Todo causado por una lista de materiales en el principio. Y Depurador muestra un rombo negro en la primera línea.
Los archivos guardados con firma, pero no ensamblados por php, no causan tales errores y los diamantes negros no son visibles en el depurador de IE. Entonces quizás php transforme BOM de alguna manera. Parece que el archivo php principal se debe guardar con la firma para ver esto.
Esos caracteres extraños se producen al principio y/o en los bordes de los archivos combinados con include_once() y no son visibles cuando los archivos se guardan antes sin firma. Esta es la razón por la que apunta a la implicación en la lista de materiales.
He notado esto todo anteayer cuando comencé a convertir mi sitio web a HTML5 y validarlo.
BOM también puede crear una pequeña sangría al principio de la línea. Dos archivos que contienen texto idéntico pero uno con sangría.
Tenía la intención de votar esto, pero lo voté accidentalmente y no me di cuenta por 2 días, y ahora está bloqueado y no me deja cambiarlo ... pero esto me ayudó a corregir las advertencias w3c que estaban molestándome, así que gracias de todos modos. – andygoestohollywood
@andygoestohollywood: :-) Gracias por explicarme, me pregunté en el momento por qué alguien había votado negativamente la respuesta. Podría editar la respuesta para poder deshacerla, pero no veo nada constructivo para cambiar y no me gusta presionarlo en la lista "activa" solo para revertir una votación. Me alegro de que esto ayudó! –