【问题标题】:Strip HTML Tags in Zend Framework在 Zend 框架中去除 HTML 标签
【发布时间】:2012-05-25 13:24:23
【问题描述】:

我正在尝试从以下输入数据中去除除 <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 吗?

【问题讨论】:

    标签: php zend-framework


    【解决方案1】:

    如果我了解您的问题:

    $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

    【讨论】:

    • 在您上面的代码中,只有一些变量的初始化和父级的 init() 调用。你想如何将这些与 Zend_Filter_StripTags 一起使用
    • 我明白了,所以我想我应该把 StripTags 放在其他地方,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-07
    • 1970-01-01
    • 2011-03-11
    • 2017-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多