I am currently experimenting with XHTML5 delivery. I am currently delivering XHTML 1.1 Strict on the page I'm working on. That is, I do for capable browsers. For those who do not accept XML encoded data, I am returning to strict HTML4.1.
In an experiment using HTML5 for both when delivered as HTML5, everything works more or less as expected. The first problem that occurs when delivering XHTML5, however, is related to HTML objects. FF4 sais ü - an undefined object. Because there is no HTML5 DTD.
I read that the HTML5 wiki currently recommends:
Do not use entity references in XHTML (except for 5 predefined objects: & ' " and ' )
I need < , > in certain places. Therefore, my question is the best way in PHP to decode all but the five objects mentioned above. html_entity_decode() decodes all of them, so is there any reasonable way to exclude some of them?
UPDATE:
At the moment, I went with a simple replacement / replacement back, so if there really is no elegant way to resolve this issue for my immediate needs.
function non_html5_entity_decode($string) { $string = str_replace("&",'@@@AMP', str_replace("'",'@@@APOS', str_replace("<",'@@@LT', str_replace(">",'@@@GT', str_replace(""",'@@@QUOT',$string))))); $string = html_entity_decode($string); $string = str_replace('@@@AMP',"&", str_replace('@@@APOS',"'", str_replace('@@@LT',"<", str_replace('@@@GT',">", str_replace('@@@QUOT',""",$string))))); return $string; }