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.