filter_input

(PHP 5 >= 5.2.0, PHP 7)

filter_inputͨ�����ƻ�ȡ�ض����ⲿ���������ҿ���ͨ��������������

˵��

filter_input ( int $type , string $variable_name [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) : mixed

����

type

INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER�� INPUT_ENV֮һ��

variable_name

����ȡ�ı�������

filter

The ID of the filter to apply. The Types of filters manual page lists the available filters.

If omitted, FILTER_DEFAULT will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no filtering taking place by default.

options

һ��ѡ��Ĺ������飬���߰�λ���ֵı�ʾ���������������ѡ�����ͨ������� "flags" λȥ�ṩ��Щ��ʾ��

����ֵ

����ɹ��Ļ�����������ı������������ʧ���򷵻� FALSE �����variable_name �����ڵĻ��򷵻� NULL �� �����ʾ FILTER_NULL_ON_FAILURE ��ʹ���ˣ���ô������������ʱ���� FALSE ��������ʧ��ʱ���� NULL ��

����

Example #1 һ�� filter_input() ������

<?php
$search_html 
filter_input(INPUT_GET'search'FILTER_SANITIZE_SPECIAL_CHARS);
$search_url filter_input(INPUT_GET'search'FILTER_SANITIZE_ENCODED);
echo 
"You have searched for $search_html.\n";
echo 
"<a href='?search=$search_url'>Search again.</a>";
?>

�������̵���������ڣ�

You have searched for Me &#38; son.
<a href='?search=Me%20%26%20son'>Search again.</a>

�μ�