(PHP 5, PHP 7, PHP 8)
DOMDocument::createComment — Crea un nuevo nodo de comentario
Esta función crea una nueva instancia de la clase DOMComment . Este nodo no será mostrado en el documento, a menos que sea insertado con DOMNode::appendChild() .
dataEl contenido del comentario.
El nuevo DOMComment .
| Versión | Descripción |
|---|---|
| 8.1.0 |
En caso de error, una DomException es lanzada ahora.
Anteriormente, false era devuelto.
|
To prevent a parser error when the comment string would contain the character sequence "--", do this:
<?php
$CommentString = 'This contains -- some weird -- characters.';
$CommentNode = $DomDocument->createComment(
str_replace('--', '-'.chr(194).chr(173).'-', $CommentString)
);
?>
This will insert a Soft Hyphen in between the two hyphens which will not cause the parser to error out.