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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:14:55+00:00 2026-05-10T21:14:55+00:00

In PHP 5.2 there was a nice security function added called input_filter, so instead

  • 0

In PHP 5.2 there was a nice security function added called ‘input_filter’, so instead of saying:

$name = $_GET['name']; 

you can now say:

$name = filter_input (INPUT_GET, 'name', FILTER_SANITIZE_STRING); 

and it automatically sanitizes your string, there is also:

  • FILTER_SANITIZE_ENCODED
  • FILTER_SANITIZE_NUMBER_INT
  • FILTER_SANITIZE_EMAIL
  • FILTER_SANITIZE_URL

etc. so this is a very convenient security feature to use and I want to switch over to it completely.

The problem is… I often manipulate the $_GET and $_POST arrays before processing them, like this:

$_GET[‘name’] = ‘(default name)’;

but it seems that filter_input does not have access to the changes in $_GET since it reads ‘INPUT_GET’ which is of type int (?). It would be nice if I could get filter_input to read $_GET instead but:

$name = filter_input ( $_GET, 'name', FILTER_SANITIZE_STRING ); 

gives me the error:

Warning: filter_input() expects parameter 1 to be long, array given. 

Can anyone think of a way that I could:

  • manipulate the source of INPUT_GET (whereever it is) so that I can change its values before filter_input can read them
  • get filter_input to read $_GET

ADDENDUM:


Rich asked: ‘Why are you changing the arrays anyway, surely you want them to be an input, rather than something you’ve programmatically inserted.’

It is just a very convenient place to preprocess variables coming in, e.g. in order to:

  • set defaults (if $_GET[‘state’] = ” then $_GET[‘state’] = ‘AL’)
  • do manual processing (delete all spaces, etc.)
  • security (some of which will be done by filter_input now)

Then I know by the time I get the incoming variable, it is secure and valid. Of course I could copy the $_GET array to another array and process THAT array but that is just an unnecessary step since I $_GET is already a functioning array so it makes sense to do it with these system arrays that already exist.

  • 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. 2026-05-10T21:14:56+00:00Added an answer on May 10, 2026 at 9:14 pm

    You could manually force it to read the arrays again by using filter_var and filter_var_array

    $name = filter_var ( $_GET['name'], FILTER_SANITIZE_STRING ); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 108k
  • Answers 108k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There isn't an easy way to place content in that… May 11, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer NVARCHAR(MAX) is a lot better at performing with smaller data… May 11, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer If your init routine is going to cause delegate/controller calls,… May 11, 2026 at 9:14 pm

Related Questions

I am writing a custom session handler in PHP and trying to make the
We have PHP 5.2.6 deployed to c:\php and in that folder there is the
I am creating a web application that acts as a priority list, allowing a
I have a fairly small MySQL database (a Textpattern install) on a server that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.