In PHP, the "filter_input()" function is used to verify variables from non-safe sources, obtain input from outside the script, and filter it. If successful, the filtered data will be returned, and if it fails, false will be returned. , the syntax is "filter_input(input type, filtered variable, filter ID, array)".
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
The filter_input() function gets input from outside the script and filters it.
This function is used to verify variables from non-safe sources, such as user input.
This function can get input from various sources:
INPUT_GET
INPUT_POST
INPUT_COOKIE
INPUT_ENV
INPUT_SERVER
filter_input(input_type, variable, filter, options)
<?php if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) { echo "E-Mail is not valid"; } else { echo "E-Mail is valid"; } ?>
PHP Video Tutorial"
The above is the detailed content of What is the usage of filter_input in php. For more information, please follow other related articles on the PHP Chinese website!