PHP htmlentities() without converting html tags
问题 I've found a few posts which refer to the problem, but none of them fully resolve it. I need the function which will output the content converting all special characters in the way the htmlentities() would, but preserving all html tags. I've tried many different approaches, but as I've mentioned above - none of them works as expected. I was wondering whether there would be a way of doing it using PHP class DomDocument. I've tried to do it using the following: $objDom = new DOMDocument('1.0',