I can’t seem to figure out how to loop a variable check. What I am trying to do is something like checking those two variables but in a loop
if(isset($_GET['action'])){
$action = $_GET['action'];
}
else{
$action = NULL;
}
if(isset($check)){
$check = $check;
}
else{
$check = NULL;
}
I want to do something like this or more effiecient if possible
$variables = array($_GET['action'], $check);
$define = array($action, $check);
foreach($variables as $variable){
if(isset($variable){
$variable = $define;
}
}
I want it to show no errors while I have error_reporting(E_ALL) open
Could someone help me with this?
Your first line will lead to warnings if the variables are not set:
If you want to write it a bit shorter, you could use the ternary operator but that’s about it:
I don’t think there is any more efficient way to check a combination of normal variables and super globals in one sweep.