i've written a little class in PHP to generate a simple RSS feed.
The item description should also be able to contain html tags.
I've wondered which one is the better way and what are the advantages/disadvantages of each method:
$item .= "<description><![CDATA[" . $description . "]]></description>
";
or
$item .= "<description>" . htmlspecialchars($description, ENT_NOQUOTES, "UTF-8") . "</description>
";
The only disadvantage of the CDATA method i can think of is, that i've to check in advance if the string $description contains
"<![CDATA[" or "]]>".
Thanks in advance for clarification.