HTMLPurifier without XML declaration

131 views Asked by At

I am using HTMLPurifier on PHP to clean some dirty HTML, as follows:

$H=new HTMLPurifier()
$content_text_fixHTML = $H->purify($content_text);

Note: Omited encoding set up, because it is UTF-8

But, it will output the XML encoding declaration at the top.

<?xml encoding="utf-8" ?>

I do not want it. How do I prevent HTMLPurifier from adding it?

Thanks for your help in advance.

1

There are 1 answers

1
AudioBubble On BEST ANSWER

you need cut result string

$n = strlen('<?xml encoding="utf-8" ?>');
$content_text_fixHTML = substr($H->purify($content_text), $n);