In my DB class i have a function to do a simple sanitize operation.
The function does three things:
1. checks weather the input variable is a integer, if it is then it gets the int value of the variable and returns it.
2. checks weather the input variable is a string, if it is then it escapes it and returns it.
3. if it is neither an integer or a string then the variable is unset and returns a "Variable deleted" message.
function sanitizeData($dbc, $input){
if(is_int($input)){
$input = intval($input);
return $input;
} elseif(is_string($input)){
$input = mysqli_real_escape_string($dbc, $input);
return $input;
} elseif(!is_int($input) OR !is_string($input)){
unset($input);
return "Variable contents unknown, variable deleted!";
}
}
I wanted other peoples ideas, opinions and suggestions on this function and what you think of it
Thanks