gpt4 book ai didi

php - 在 Zend Framework 中去除 HTML 标签

转载 作者:可可西里 更新时间:2023-10-31 22:07:45 24 4
gpt4 key购买 nike

我正在尝试去除除 <p>,<br>,<strong>,<b> 之外的所有 html 标签来自以下输入数据:

    public function init()
{
parent::init();
$this->fields = array(
'name' => 'Name',
'age' => 'Age',
'profile' => 'Profile',
);

$this->mdata = array();
$this->verify = true;
}

有人知道如何在其中应用 Zend_Filter_StripTags 吗?

最佳答案

如果我理解你的问题:

$allowedTags = array('p','b','br','strong'); // Allowed tags
$allowedAttributes = array('href'); // Allowed attributes
$stripTags = new Zend_Filter_StripTags($allowedTags,$allowedAttributes); // instance of zend filter
$sanitizedInput = $stripTags->filter($input); //$input is input html

See this SO answer

关于php - 在 Zend Framework 中去除 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3336582/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com