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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:09:19+00:00 2026-05-27T11:09:19+00:00

I noticed there are many things you can do with the PHP filter_var function

  • 0

I noticed there are many things you can do with the PHP filter_var function which can also be done with other function.

For example, the filters FILTER_VALIDATE_REGEXP, FILTER_SANITIZE_ENCODED and many more also have their respective dedicated functions in PHP.

When should I use filter_var and when should I use the PHP functions? What are the advantages and disadvantages?

  • 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-27T11:09:19+00:00Added an answer on May 27, 2026 at 11:09 am

    The advantage of the filter extension is that you have everything in one place.

    But you are right, it doesn’t provide much novel features. You could do most of the stuff with existing functions, in particular preg_replace or preg_match instead of FILTER_VALIDATE_REGEXP. Or typecasting, and using the normal htmlspecialchars instead of the filter option.

    There is however filter_var_array, where one benefit becomes apparent. You can filter loads of variables per config. And you can predefine a list of filters to apply all at once:

    $_POST = filter_var_array($_POST, array(
        "text" => FILTER_SANITIZE_ENCODED,
        "id" => FILTER_VALIDATE_INT,
        "title" => FILTER_SANITIZE_ENCODED,
    ));
    

    I admit that’s basically a triggered magic_quotes example, but you get the picture. Unification.

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

Sidebar

Related Questions

There are web browser apps in the store which do many things that seem
I've already noticed that there are many posts dealing with this; but I can't
First, I noticed there are many questions regarding this, lots marked as duplicate. I
I have tried many PHP MVC frameworks and I noticed that in many frameworks
Many editors will notice when a file changes out from under them. Are there
I've noticed there are a few solutions to allow the use of memcached on
I just noticed there is no * in front of the declaration for a
I'm using ASP.NET Membership and noticed there isn't a method in the Roles class
Once again I'm doing Java graphics (Graphics2D) but I noticed there is no Polygon.Double
When I run get-user|get-member in powershell with the exchange add-in I noticed there is

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.