Skip to content
Advertisement

Character entities in PHP and SVG

For my HTML content I have been using htmlentities($instring,ENT_QUOTES|ENT_HTML401,"UTF-8",false) to replace certain characters with HTML entities. However, I also serve SVG content, and some of the entities are not understood, such as …. Is there a special PHP function for character entities in SVG?

Advertisement

Answer

Use ENT_XML1 instead of ENT_HTML401. SVG uses XML:

htmlentities($instring,ENT_QUOTES|ENT_XML1,"UTF-8",false)
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement