The Ilter_var () function filters variables by the specified filter.
If successful, returns the filtered data, or false if it fails.
Grammar
Filter_var (variable, filter, options)
Variable: Required. Specifies the variables to filter.
Filter: Optional. Specifies the ID of the filter to be used. (see List of Filtersid below)
Options: Specifies an array containing the flags/options. Check the possible flags and options for each filter.
<?
@header (' content-type:text/html;charset=utf-8; ');
$email _a= ' [email protected] ';
$email _b= ' @[email protected] ';
$email _c= ' jcifoxgmail.com ';
$ip _a= ' 0.0.0.0 ';
$ip _b= ' 255.255.255.255 ';
$ip _c= ' 0.0.0.265 ';
echo $email _a. ': ';
Echo (Filter_var ($email _a,filter_validate_email))? ' is valid ': ' was not valid ';
Echo ' <br/><br/> ';
echo $email _b. ': ';
Echo (Filter_var ($email _b,filter_validate_email))? ' is valid ': ' was not valid ';
Echo ' <br/><br/> ';
echo $email _c. ': ';
Echo (Filter_var ($email _c,filter_validate_email))? ' is valid ': ' was not valid ';
Echo ' <br/><br/> ';
echo $ip _a. ': ';
Echo (Filter_var ($ip _a,filter_validate_ip))? ' is valid ': ' was not valid ';
Echo ' <br/><br/> ';
echo $ip _b. ': ';
Echo (Filter_var ($ip _b,filter_validate_ip))? ' is valid ': ' was not valid ';
Echo ' <br/><br/> ';
echo $ip _c. ': ';
Echo (Filter_var ($ip _c,filter_validate_ip))? ' is valid ': ' was not valid ';
?>
Filtersid Name: Description
Filter_callback: Invokes a user-defined function to filter the data.
filter_sanitize_string: Remove tags, remove or encode special characters.
filter_sanitize_stripped: Alias of the "string" filter.
filter_sanitize_encoded: url-encode string, removing or encoding special characters.
filter_sanitize_special_chars: HTML escape character ' "<>& and ASCII values less than 32 characters.
filter_sanitize_email: Remove all characters except letters, numbers, and!#$%& ' *+-/=?^_ ' {|} [Email protected] []
filter_sanitize_url: Delete all characters except letters, numbers, and $-_.+!* ' (), {}|\\^~[] ' <>#% ';/?:@&=
filter_sanitize_number_int: Remove all characters except numbers and +-
filter_sanitize_number_float: Delete all characters except numbers, +-and., EE.
filter_sanitize_magic_quotes: Apply Addslashes ().
Filter_unsafe_raw: Do not filter, remove or encode special characters.
Filter_validate_int: Validates the value with an integer in the specified range.
Filter_validate_boolean: Returns True if "1", "true", "on", and "yes", and returns False if it is "0", "false", "off", "No", and "". Otherwise, NULL is returned.
filter_validate_float: Validates the value with a floating-point number.
filter_validate_regexp: Validates values based on REGEXP, a Perl-compatible regular expression.
Filter_validate_url: Validates the value as a URL.
filter_validate_email: Verify the value as an e-mail.
filter_validate_ip: Validates the value as an IP address.