$config
->set(
$option
[0],
$option
[1],
$option
[2]);
}
}
$this
->_htmlPurifier =
new
HTMLPurifier(
$config
);
}
public
function
filter(
$value
)
{
return
$this
->_htmlPurifier->purify(
$value
);
}
}
?>
设置 config 信息
例如:
代码如下:
$conf
=
array
(
array
('HTML.AllowedElements',
array
(
'div' => true,
'table' => true,
'tr' => true,
'td' => true,
'br' => true,
),
false),
//
允许属性 div table tr td br 元素
array
('HTML.AllowedAttributes',
array
('class' => TRUE), false),
//
允许属性 class
array
('Attr.ForbiddenClasses',
array
('resume_p' => TRUE), false),
//禁止 classes 如
array
('AutoFormat.RemoveEmpty', true, false),
//去空格
array
('AutoFormat.RemoveEmpty.RemoveNbsp', true, false),
//去 nbsp
array
('URI.Disable', true, false),
);
调用
复制代码 代码如下:
$p
=
new
Resume_HtmlPurifier(
$conf
);
$puri_html
=
$p
->filter(
$html
);