Copy link to clipboard
Copied
I am using the following to sanitize input prior to validating:
if(filter_has_var(INPUT_POST, "$var")) {
$sanitized = filter_input(INPUT_POST, '$var', FILTER_SANITIZE_STRING);
$_POST['$var'] = trim($sanitized);
Is it preferable to use filter_has_var() to check the input or isset()? Is there a difference and what is it?
Thank you in advance for any help.
According to an anonymous note in the PHP documentation, filter_has_var() is slightly faster than isset(). I've no idea if that's accurate, but it hasn't been removed by the PHP documentation team, so it seems legitimate.
Other than that, there's no difference.
Copy link to clipboard
Copied
According to an anonymous note in the PHP documentation, filter_has_var() is slightly faster than isset(). I've no idea if that's accurate, but it hasn't been removed by the PHP documentation team, so it seems legitimate.
Other than that, there's no difference.