Course Recommendation:

PHP filter_var() Function

Definition and Usage

The filter_var() function filters the variable through the specified filter.

If successful, returns filtered data, if failed, 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 Define an array containing flags/options. Check each filter's possible flags and options.

Tips and Comments

Tip:See alsoComplete PHP Filter Reference Manual, see 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