Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Unsetting Superglobal Variable Properly

I've recently switched from Dreamweaver to Netbeans and, with the built-in accountability for clean code, I've realized I have some work to do in writing proper/clean code.

Currently, I'm trying to adjust from accessing SuperGlobals (such as $_POST) directly. For this question, specifically, I am trying to figure out how to handle unsetting a SuperGlobal variable temporarily.

$sampleArray = ["Designer_Name" => "someName",
            "Designer_Key" => "someName's UID",
            "Designer_Store" => "someStoreName",
            "Group_Name" => "someGroupName",
            "Dropbox_Key" => "someUID"
            ];

Normally, I might do something like this:

unset($_POST['Dropbox_Key']);

In this particular problem, I am trying to use short amounts of code. I know that I can filter/sanitize each element of the array and assign it to a variable, but since the $_POST array is not user-input, I'm not too concerned with that.

With this array, I'll be inserting the entire array into a database table, minus the last element. I don't need 'Dropbox_Key' for the same table as the rest of the array. I will use that element later for another table.

The insert code would look like this:

$insert = $dbs->insert('sometable', filter_input_array(INPUT_POST));

So, the question I am asking is, despite it being easier to ignore the netbeans warnings of accessing SuperGlobals, is there some current/cleaner way to do what I intend (the unsetting of the $_POST element), or is ignoring the warning the best way to go here?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The reason we use filter_input() on super global input's like $_POST is because it tends to be user entered data we cannot trust. By filtering we can escape and sanitize the inputs to help prevent XSS (cross-site scripting) and SQLinjections.

In the case of un-setting super global's in your own code there is no risk posed (You are in control of your code), so we can safely unset directly unset($_POST['Dropbox_Key']);

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!