- filter_has_var: documentation ( source)
- var_dump: documentation ( source)
- filter_input: documentation ( source)
<?php
// Get rid of the global $_GET variable
unset($_GET);
// Recreate it as a closure
$_GET = function($varName) {
return filter_input(INPUT_GET, 'test', FILTER_SANITIZE_STRING);
// a closure must have a semicolon at the end
};
?>
<hr>
Globals variables defined after creating function:
<br/>
<?php var_dump($GLOBALS); ?>
<?php
// get query string variable 'test'
$var = $_GET('test');
?>
My var is <?= $var; ?>
<hr>
<?php
if (filter_has_var ( INPUT_GET , 'test' ))
{
echo 'input get has test';
} else
{
echo 'input get has not test';
}