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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version
SublimeText3 Linux latest version
