filter_var() function in PHP

PHPz
Release: 2023-09-09 20:42:02
forward
866 people have browsed it

filter_var() function in PHP

The filter_var() function is used to filter variables using the specified filter.

Syntax

filter_var(variable, filter, options)
Copy after login

Parameters

  • variable − The name of the variable.

  • #filter − The name of the filter whose ID is to be obtained.

  • options − Specifies the options to use.

Return value

The filter_var() function returns filtered data when successful, and returns false when failed.

Example

Demonstration

<?php
   $myEmail = "examplee@demo.com";
   if (filter_var($myEmail, FILTER_VALIDATE_EMAIL {
      echo("$myEmail = valid email address");
   } else {
      echo("$myEmail = invalid email address");
   }
?>
Copy after login

Output

The following is the output result.

examplee@demo.com = valid email address
Copy after login

The above is the detailed content of filter_var() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!