I've always been used to using
isset to check if an external variable is filled and if you are using it.
if(isset($_GET['pag'])) $pag = $_GET['pag'];
if($pag = filter_input(INPUT_GET , 'pag'));
Are there any advantages to using the
As it can be read in the documentation of the filter_input function (English) :
filter_input — Gets a specific external variable by name and optionally filters it
filter_input — Gets a specific external variable by name and optionally filters its value.
The advantage of using the
filter_input function is the fact that not only will we collect the value, but we can also filter it during this collection:
$search_html = filter_input(INPUT_GET, 'chavePesquisa', FILTER_SANITIZE_SPECIAL_CHARS);
Useful to protect, clean or validate user data without using multiple functions and several lines of code.
The list of filters can be found here: