yii过滤不良代码

$purifier=new CHtmlPurifier;
$purifier->options=array('HTML.Allowed'=>'div');
$content=$purifier->purify($content);

或者

<?php $this->beginWidget('CHtmlPurifier'); ?>
...display user-entered content here...
<?php $this->endWidget(); ?>

你可能感兴趣的:(yii)