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 8584685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:49:47+00:00 2026-06-11T21:49:47+00:00

I am creating a validation script which is way more advanced than this little

  • 0

I am creating a validation script which is way more advanced than this little section, I am just printing the specific part I am having issues with.

The script simply takes in a single dimensional array with a list of settings, performs required tests and spits out a multidimensional array with the required string, all clean free of badness.

For some reason the trim() strip_tags() strip_html_tags() functions are working but failing at the same time. By this I mean the string is passed through the functions and showing as clean but the built-in PHP functions aren’t working as expected.

The question is do the built in functions only work on text that is directly output to the user or should the functions work pre output ie as it is being output not while being stored in a database?

I’m looking to strip all script tags as the user inputs so I only have the plain text.

I was wanting to use a switch with each statement which I have the functions below are snippets from switch statements.

What I am trying to use which doesn’t work as expected.

function check_input1($input)
{
    if(trim($input))
    {
        $cleaninput[$i][$input] = 'CLEAN';
    }else
        $cleaninput[$i][$input] = 'DIRTY';
}


function check_input2($input)
{
    if(strip_tags($input))
    {
       $cleaninput[$i][$input] = 'CLEAN';
    }else
       $cleaninput[$i][$input] = 'DIRTY';
}



function check_input3($input)
{
    if(strip_html_tags($input))
    {
       $cleaninput[$i][$input] = 'CLEAN';
    }else
       $cleaninput[$i][$input] = 'DIRTY';
}

What I know works directly output in html elements.

strip_tags(trim($key))
strip_tags(trim($value))
  • 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-06-11T21:49:48+00:00Added an answer on June 11, 2026 at 9:49 pm

    The question is do the built in functions only work on text that is directly output to the user or should the functions work pre output ie as it is being output not while being stored in a database?

    The functions in question work on any string. There is no different between a string destined for the database vs a string destined for stdout.

    Your problem is that you seem to be expecting the functions to return true/false, as some kind of indication that they found something to strip. That’s not how they work. They return the modified string. Every single if condition will enter the CLEAN section (assuming its function doesn’t return ""), and silently throw away the cleaned string which was returned by the function.

    What you want is something like this:

    function check_input3($input)
    {
        $output = strip_html_tags($input);
    
        if ($output == $input) {
            // strip_html_tags didn't remove anything
            $cleaninput[$i][$input] = 'CLEAN';
        } else {
            // variables differ, so strip_html_tags found something to remove
            $cleaninput[$i][$input] = 'DIRTY';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently creating a form validation script based on the jQuery validator plugin .
I am creating a form validation script and I have check box's on a
I'm creating a validation script for a multi-step form, each group is inside a
Hi guys i am creating a validation for checking if the user has selected
I'm creating a registration form using validation inside the User model such as validates_confirmation_of
can any one help me in creating a regular expression for password validation. The
I'm creating web site in asp.net web forms. I added validation to fields in
I was trying to create Hibernate Validator bean, and run into this problem creating
The W3C HTML validator reports errors in lines which are inside script <script> tags.
I'm creating a DataAnnotations validation attribute for matching emails using the same pattern as

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.