PHP filter_var () function

Source: Internet
Author: User
Tags encode string php tutorial

Introduction to filter in php Tutorial

Php filters are used to verify and filter data from unsafe sources (such as user input.

Install

The filter function is a core component of php. These functions can be used without installation.

Php filter function

Php: indicates the earliest php version that supports this function.

Function Description Php
Filter_has_var () Check whether a variable of the specified input type exists. 5
Filter_id () Returns the id of the specified filter. 5
Filter_input () Obtain and filter the input from outside the script. 5
Filter_input_array () Obtain multiple inputs from outside the script and filter them out. 5
Filter_list () Returns an array containing all the supported filters. 5
Filter_var_array () Obtain and filter multiple variables. 5
Filter_var () Obtain and filter a variable. 5

Php filters

Id Description
Filter_callback You can call a user-defined function to filter data.
Filter_sanitize_string Remove tags, remove or encode special characters.
Filter_sanitize_stripped The alias of the "string" filter.
Filter_sanitize_encoded Url-encode string to remove or encode special characters.
Filter_sanitize_special_chars Html escape character '"<> & characters with ascii values smaller than 32.
Filter_sanitize_email Delete 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 filter, remove, or encode special characters.
Filter_validate_int The value is verified by an integer in the specified range.
Filter_validate_boolean If it is "1", "true", "on", and "yes", true is returned. If it is "0", "false", "off ", "no" and "", false is returned. Otherwise, null is returned.
Filter_validate_float Verify the value with a floating point number.
Filter_validate_regexp Verify the value based on regexp and perl-compatible regular expressions.
Filter_validate_url Use the value as the url for verification.
Filter_validate_email Use the value as email for verification.
Filter_validate_ip Use the value as the ip address for verification.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.