Character entities in PHP and SVG

174 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

Use ENT_XML1 instead of ENT_HTML401. SVG uses XML:

htmlentities($instring,ENT_QUOTES|ENT_XML1,"UTF-8",false)