php filters are used to verify and filter data from non-secure sources (such as user input). the filter function is an important part of the php filter. this chapter introduces you to the filter_var() function in the php filter function. there are it has a certain reference value. friends in need can refer to it. i hope it will be helpful to you.
the filter_var() function filters a variable through a specified filter.
returns filtered data if successful, false if failed.
syntax:
filter_var(variable, filter, options)
variable: required. specifies the variables to filter.
filter: optional. specifies the id of the filter to use. (see filtersid list below)
options: specifies an array containing flags/options. check the possible flags and options for each filter.
<? @header('content-type:text/html;charset=utf-8;'); $email_a='jcifox@gmail.com'; $email_b='@jcifox@gmail.com'; $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':'is not valid'; echo '<br /><br />'; echo $email_b.' : '; echo (filter_var($email_b,FILTER_VALIDATE_EMAIL))?'is valid':'is not valid'; echo '<br /><br />'; echo $email_c.' : '; echo (filter_var($email_c,FILTER_VALIDATE_EMAIL))?'is valid':'is not valid'; echo '<br /><br />'; echo $ip_a.' : '; echo (filter_var($ip_a,FILTER_VALIDATE_IP))?'is valid':'is not valid'; echo '<br /><br />'; echo $ip_b.' : '; echo (filter_var($ip_b,FILTER_VALIDATE_IP))?'is valid':'is not valid'; echo '<br /><br />'; echo $ip_c.' : '; echo (filter_var($ip_c,FILTER_VALIDATE_IP))?'is valid':'is not valid'; ?>
filtersid name: description
filter_callback: call user-defined function to filter data.
filter_sanitize_string: remove tags, remove or encode special characters.
filter_sanitize_stripped: alias of "string" filter.
filter_sanitize_encoded: url-encode string, remove or encode special characters.
filter_sanitize_special_chars: html escape characters '"& and characters with ascii value less than 32.
filter_sanitize_email: remove all characters except letters, numbers and !#$%&'* - /=?^_`{|}~@.[]
filter_sanitize_url: delete all characters, except letters, numbers and $-_. !*'(),{}|\\^~[ ]`#%";/?:@&=
filter_sanitize_number_int: delete 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 perform any filtering, remove or encode special characters.
filter_validate_int: validates values as integers in the specified range.
filter_validate_boolean: if it is "1", "true", "on" and "yes", return true, if it is "0", "false", "off", "no" and " ", returns false. otherwise null is returned.
filter_validate_float: validate the value as a floating point number.
filter_validate_regexp: validate values based on regexp, a perl-compatible regular expression.
filter_validate_url: validate the value as a url.
filter_validate_email: validate the value as e-mail.
filter_validate_ip: validates the value as an ip address.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function