HTMLPurifier在引号前插入\

In the system I'm building I use CKEditor for writing posts. Then, when I send it to PHP I validate the html created from CKEditor with HTMLPurifier. The problem is that the HTMLPurifier adds \ before ". For example, the CKEditor produces:

<span style="font-size:36px;">

And after HTMLPurifier:

<span style=\"font-size:36px;\">

I'm using PHP 5.2. Why does HTMLPurifier adds these backslashes and what must I do to fix it?

It's not HTML purifier that adds the extra slashes, but your PHP configuration. Edit php.ini and disable magic_quotes_gpc.

The linked manual suggests you to add the next setting to php.ini:

magic_quotes_gpc = Off

If you are using Apache and can use .htaccess files, create one with:

php_flag magic_quotes_gpc Off

Use stripslashes() to get rid of them.

$string = '<span style=\"font-size:36px;\">';
echo stripslashes($string); // Output: <span style="font-size:36px;">