Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda