public function get($item) {
if (isset($_POST[$item]) && $_POST[$item] != '') {
$_POST[$item] = filter_var($_POST[$item],FILTER_SANITIZE_SPECIAL_CHARS);
if(is_numeric($_POST[$item])) {
return (int)$_POST[$item];
}
return $_POST[$item];
}else if (isset($_GET[$item]) && $_GET[$item] != '') {
$_GET[$item] = filter_var($_GET[$item],FILTER_SANITIZE_SPECIAL_CHARS);
if(is_numeric($_GET[$item])) {
return (int)$_GET[$item];
}
return $_GET[$item];
}
return '';
}
Is there a way I can make this more efficient? And/Or can you help me improve this code? I want to check if there is value into the $_GET / $_POST array. And filter all the evil input from a bad user.