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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:39:27+00:00 2026-06-01T13:39:27+00:00

I am wondering where the best place to filter user submitted input is. In

  • 0

I am wondering where the best place to filter user submitted input is. In regards to filter, I am talking about filter_var and filter_input.

I’ve come up with three scenarios:

  1. Filter data from POST/GET, and pass filter data to function which takes it as-is.
  2. Take raw data from POST/GET, and pass as-is to function where the function filters it.
  3. Filter data from POST/GET, and filter is a second time in the function.

Each of these methods has its advantages and disadvantages. I was looking for some insight into which may be best or standard practice.

Method 1 passes sanitized data to the function, and thus functions can be smaller not having to sanitize everything coming in. The downfall is if any other place your function is called and the data isn’t sanitized, this can lead to problems. This simply requires good coding practice to remember to sanitize everything before passing to a function.

Method 2 you will never have to worry about your function dealing with unsanitized data, but the functions will be bigger.

Method 3 is the safest, but is wasteful. More code is written, and data may be sanitized multiple times as it passes through possibly various functions, wasting CPU resources and time.

  • 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-01T13:39:29+00:00Added an answer on June 1, 2026 at 1:39 pm

    From the above-mentioned scenarios, 1 & 2 are applicable for good practice. While number 3 is unnecessary to filter input data twice as you said it waste resources.

    Thus, scenario 1 or 2; it depends on what situation you are dealing with.

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

Sidebar

Related Questions

I'm wondering what is the best place to put the viewport tag. after <title>
I was wondering where is the best place to initialize members of the singleton
Just wondering the best way to replace in place matches on a string. value.replace(bob,
I'm wondering about best practice here. Is it good practice for a factory method
I'm new to web development and am just wondering about best practices for java
I have rails app and am wondering the best place to store the constants?
I am wondering where the best place to instantiate the castle Windsor container is
I'm new to codeigniter and was wondering where the best place is to store
I am wondering where the best place to put XSS protection in our website.
I'm wondering where the best place to put Type specific functions is when using

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.