note 94806 added to domdocument.createcomment
| From: | php dot sirlancelot at spamgourmet dot com | Date: | Wed, 25 Nov 2009 20:10:32 +0000 |
| Subject: | note 94806 added to domdocument.createcomment | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163288@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 192.41.40.227
Probable Submitter: 69.163.180.47
----
Manual Page -- http://www.php.net/manual/en/domdocument.createcomment.php
Edit -- https://master.php.net/note/edit/94806
Del: integrated -- https://master.php.net/note/delete/94806/integrated
Del: useless -- https://master.php.net/note/delete/94806/useless
Del: bad code -- https://master.php.net/note/delete/94806/bad+code
Del: spam -- https://master.php.net/note/delete/94806/spam
Del: non-english -- https://master.php.net/note/delete/94806/non-english
Del: in docs -- https://master.php.net/note/delete/94806/in+docs
Del: other reasons-- https://master.php.net/note/delete/94806
Reject -- https://master.php.net/note/reject/94806
Search -- https://master.php.net/manage/user-notes.php