Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 689907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:22:52+00:00 2026-05-14T02:22:52+00:00

I’m trying to use the following code and it still strips out all the

  • 0

I’m trying to use the following code and it still strips out all the tags. Am I doing something wrong? I’m using the newest V1.10

$allowed_tags = array('img', 'object', 'param', 'embed', 'a', 'href', 'p', 'br', 'em', 'strong', 'li', 'ol', 'span');
$allowed_attributes = array('style', 'src', 'alt', 'href', 'width', 'height', 'value', 'name', 'type', 'embed', 'quality', 'pluginspage');
Zend_Loader::loadClass('Zend_Filter_StripTags');
$html_filter = new Zend_Filter_StripTags($allowed_tags, $allowed_attributes);

$post = $html_filter->filter($this->_request->getPost('post'));

For a test case I’ve been using the same string, this is what’s going in

<p><span style="background-color: #333399; color: #ff9900; text-decoration: underline;"><em><strong>This is a test</strong></em></span></p>

<p><span style="background-color: #333399; color: #ff9900;"><strong><em><sub><span style="background-color: #ffffff;"><span style="color: #000000;">asdf</span></span></sub></em></strong></span></p>

<p><span style="background-color: #333399; color: #ff9900;"><strong><em><span style="background-color: #ffffff;"><span style="color: #000000;"><sup>asdf</sup></span></span></em></strong></span></p>

<p><span style="background-color: #333399; color: #ff9900;"><strong><em><span style="background-color: #ffffff;"><span style="color: #000000;"><img title="Cool" src="../../../public/scripts/tinymce/plugins/emotions/img/smiley-cool.gif" border="0" alt="Cool" />asdf</span></span></em></strong></span></p>

<ul>

<li><span style="background-color: #333399; color: #ff9900;"><strong><em><span style="background-color: #ffffff;"><span style="color: #000000;">sadf</span></span></em></strong></span></li>

</ul>

<ol>

<li><span style="background-color: #333399; color: #ff9900;"><strong><em><span style="background-color: #ffffff;"><span style="color: #000000;">asdf</span></span></em></strong></span></li>

</ol>

This is what comes out

This is a test

asdf

asdf

asdf

sadf

asdf


Alternatively, perhaps there’s something else wrong, as I just tried this:

$post = strip_tags($this->_request->getPost('elm1'), '<img><object><param><embed><a><href><p><br><em><strong><li><ol><span>');

And it stripped out everything as well. Perhaps there is a setting in PHP that I’m missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:22:52+00:00Added an answer on May 14, 2026 at 2:22 am

    According to the API Doc for the StripTag Filter, the constructor signature is

    void   __construct  ([string|array|Zend_Config $options = null]) 
    

    So it should work with this (updated):

    $html_filter = new Zend_Filter_StripTags(array(
      'allowTags' => $allowed_tags, 
      'allowAttribs' => $allowed_attributes
    ));
    

    In earlier versions of Zend Framework (1.8.4) you had to do

    $html_filter = new Zend_Filter_StripTags($allowed_tags, $allowed_attributes);
    

    All versions should support:

    $html_filter = new Zend_Filter_StripTags;
    $html_filter->setAttributesAllowed($allowed_attributes);
    $html_filter->setTagsAllowed($allowed_tags);
    

    Internally, StripTags works with str_replace and preg_replace. So even if someone added strip_tags() to the list of disallowed functions in your php.ini, the filter should work.

    I’ve tried with your example code and it worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.