过滤器

属性
命名空间 fize\security
类名 Filter
方法:
方法名 说明
hasVar() 判断是否有传递某参数
id() 返回与某个特定名称的过滤器相关联的 id
inputArray() 获取一系列外部变量,并且可以通过过滤器处理它们
input() 通过名称获取特定的外部变量,并且可以通过过滤器处理它
list() 返回所支持的过滤器列表
varArray() 获取多个变量并且过滤它们
var() 使用特定的过滤器过滤一个变量

方法

hasVar()

判断是否有传递某参数

public static function hasVar (
    int $type,
    string $variable_name
) : bool
参数:
名称 说明
type 类型
variable_name 参数名
参数 `$type` :
INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV 值其中一个

id()

返回与某个特定名称的过滤器相关联的 id

public static function id (
    string $filtername
) : int
参数:
名称 说明
filtername 过滤器名称

inputArray()

获取一系列外部变量,并且可以通过过滤器处理它们

public static function inputArray (
    int $type,
    mixed $definition,
    bool $add_empty = true
) : mixed
参数:
名称 说明
type 类型
definition 定义过滤器参数
add_empty 在返回值中添加 NULL 作为不存在的键。
参数 `$type` :
INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV 值其中一个

input()

通过名称获取特定的外部变量,并且可以通过过滤器处理它

public static function input (
    int $type,
    string $variable_name,
    int $filter = 516,
    mixed $options = null
) : mixed
参数:
名称 说明
type 类型
variable_name 待获取的变量名
filter 指定过滤器
options 指定过滤器参数
参数 `$type` :
INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV 值其中一个

list()

返回所支持的过滤器列表

public static function list () : array

varArray()

获取多个变量并且过滤它们

public static function varArray (
    array $data,
    mixed $definition,
    bool $add_empty = true
) : mixed
参数:
名称 说明
data 一个键为字符串,值为待过滤的数据的数组
definition 一个定义参数的数组
add_empty 在返回值中添加 NULL 作为不存在的键

var()

使用特定的过滤器过滤一个变量

public static function var (
    mixed $variable,
    int $filter = 516,
    mixed $options = null
) : mixed
参数:
名称 说明
variable 待过滤的变量
filter 指定过滤器 ID
options 指定过滤器参数