CHtmlPurifier Remove all html tags

Hello,

I have a form which is posted to the server. I want to remove all html tags which the user can have entered.

I watched at the demo of htmlpurifier it can do it, but I don’t get it work with yii.


$p = new CHtmlPurifier();

$p->options = array('HTML.Allowed'=>'');

$text = 'text <b>strong</b>';

echo $p->purify($text);

Can someone help me please on this ?

You can always use the PHP strip_tags() function - http://us.php.net/manual/en/function.strip-tags.php

I believe he asked how to this with Yii.

Hi,

CHtmlPurfier is just wrapper of HTML Purifier library.

You might want to see their documentation about that

Depending on your case, the code should be like this.

In this example, i purify <p> tags




$CHtmlPurifier = new CHtmlPurifier();

$CHtmlPurifier->options = array('HTML.ForbiddenElements' => array('p'));

echo $CHtmlPurifier->purify('<p>Testing</p>');



*sorry i can’t give url from their documentation. Rule from this forum.