Course Recommendation:
PHP filter_var() Function
Definition and Usage
The filter_var() function filters the variable through the specified filter.
If successful, it returns filtered data; if failed, it returns false.
Syntaxvariablefilter_var( filterfilter_var( options)
, | Description |
---|---|
variable | Required. Specify the variable to be filtered. |
filter | Optional. Specify the ID of the filter to be used. |
options | Specify an array containing flags/options. Check each filter's possible flags and options. |
Tips and Comments
Tip:SeeComplete PHP Filter Reference Manual,view the filters that can be used with this function.
Example
<?php if(!filter_var("someone@example....com", FILTER_VALIDATE_EMAIL)) { echo("E-mail is not valid"); } else { echo("E-mail is valid"); } ?>
Output similar to:
E-mail is not valid