Convert critical characters to HTML entities.
DOMDocument will convert HTML entities to its actual characters. This can lead into situation when not allowed characters will appear in the content.
string $string: String to escape.
string Escaped string.
protected function toEntities($string) {
return str_replace(array(
'&',
'>',
'<',
), array(
'&',
'>',
'<',
), $string);
}