filter_input
filter_input
Gets a specific external variable by name and optionally filters it
mixed **filter_input** int $type string $var_name int $filter $options
type
One of the constants.
INPUT_*
Waarschuwing: > The content of the superglobal that is being filtered is the original "raw" content provided by the , prior to any user modification to the superglobal. To filter a modified superglobal use instead.
filter_var
var_name
Name of a variable to filter inside the corresponding
superglobal.
type
On success returns the filtered variable.
If the variable is not set false is returned.
On failure false is returned,
unless the flag is used,
in which case null is returned.
FILTER_NULL_ON_FAILURE
Voorbeeld: A example
<?php
$search_html = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_SPECIAL_CHARS);
$search_url = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_ENCODED);
echo "You have searched for $search_html.\n";
echo "<a href='?search=$search_url'>Search again.</a>";
?>
You have searched for Me & son.
<a href='?search=Me%20%26%20son'>Search again.</a>
filter_input_array``filter_var``filter_var_array``FILTER_VALIDATE_*``FILTER_SANITIZE_*