I have now a function like this
function checkInput($content, $emptyMessage = ""){
if(isset($content)){
return sanitize($content);
}else{
return $emptyMessage;
}
}
And I use it like this:
/* First get all data out of key and put it in array*/
//now check the input if user has set certain fields
$email = checkInput($user["email"],"No email address given");
echo $email;
Now I get: Uncaught ErrorOrWarningException. I can think of two solutions:
Turning off errors > dont like that one.
Do manually for every field like
if(isset($user["email"])){
$email = sanitize($user["email"]);
}else{
$email = "No email address given";
}
echo $email;
That sucks for readibility. Another way would be to try / catch but thats almost the same length to type
filter_var()and just worry about passing in the correct options?