I traditionally use a function filter_var()to disinfect data $_GETand $_POST, such as:
$foo = filter_var($_GET['foo'], FILTER_SANITIZE_NUMBER_INT);
but PHP also has a function filter_input()that has a different syntax to do the same thing:
$foo = filter_input(INPUT_GET, 'foo', FILTER_SANITIZE_NUMBER_INT);
Are these synonyms? Is there an advantage to using one over the other?
I checked the man pages, but I don't see much difference (only if / as an error is reported). Semantically / best practice, what makes the most sense?
source
share