时间:2021-09-27 09:44:33 | 栏目:PHP代码 | 点击:次
ID (过滤器常量) |
名称 (filter_list()函数返回的名称) |
可用选项 | 标志位 | 描述 |
---|---|---|---|---|
Validating | ||||
FILTER_VALIDATE_BOOLEAN | "boolean" | FILTER_NULL_ON_FAILURE | 当难的数据为"1","true","on","yes"时返回true,否则返回false。当设置了FILTER_NULL_ON_FAILURE标志位,则仅在值是"0","false","off","no", 和""是返回false,其它非true值返回null。 | |
FILTER_VALIDATE_EMAIL | "validate_email" | 验证邮箱 | ||
FILTER_VALIDATE_FLOAT | "float" | decimal | FILTER_FLAG_ALLOW_THOUSAND | 验证浮点数 |
FILTER_VALIDATE_INT | "int" | min_range, max_range | FILTER_FLAG_ALLOW_OCTAL, FILTER_FLAG_ALLOW_HEX | 验证一个指定范围内的整数值 |
FILTER_VALIDATE_IP | "validate_ip" | FILTER_FLAG_IPV4, FILTER_FLAG_IPV6, FILTER_FLAG_NO_PRIV_RANGE, FILTER_FLAG_NO_RES_RANGE | 验证IP地址 | |
FILTER_VALIDATE_REGEXP | "validate_regexp" | regexp | 验证一个正则表达式 | |
FILTER_VALIDATE_URL | "validate_url" | FILTER_FLAG_PATH_REQUIRED, FILTER_FLAG_QUERY_REQUIRED | 验证一个URL | |
Sanitizing | ||||
FILTER_SANITIZE_EMAIL | "email" | 移除除英文字符,数字以及!#$%&'*+-/=?^_`{|}~@.[]之外的字符。 | ||
FILTER_SANITIZE_ENCODED | "encoded" | FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_LOW, FILTER_FLAG_ENCODE_HIGH | URL编码字符串,去除或编码指定字符串。 | |
FILTER_SANITIZE_MAGIC_QUOTES | "magic_quotes" | 应用 addslashes()函数 | ||
FILTER_SANITIZE_NUMBER_FLOAT | "number_float" | FILTER_FLAG_ALLOW_FRACTION, FILTER_FLAG_ALLOW_THOUSAND, FILTER_FLAG_ALLOW_SCIENTIFIC | 移除除数字,+-以及.,eE以外的字符 | |
FILTER_SANITIZE_NUMBER_INT | "number_int" | 移除除数字以及+-以外的字符 | ||
FILTER_SANITIZE_SPECIAL_CHARS | "special_chars" | FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_HIGH | HTML转义字符,'"&><以及 ASCII 值小于 32 的字符。以及其它指定的字符。 | |
FILTER_SANITIZE_STRING | "string" | FILTER_FLAG_NO_ENCODE_QUOTES, FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_LOW, FILTER_FLAG_ENCODE_HIGH, FILTER_FLAG_ENCODE_AMP | 去除标签,或是去除或编码指定的字符。 | |
FILTER_SANITIZE_STRIPPED | "stripped" | Alias of "string" filter. | ||
FILTER_SANITIZE_URL | "url" | 删除所有字符除字母、数字以及$-_.+!*'(),{}|\\^~[]`<>#%";/?:@&= | ||
FILTER_UNSAFE_RAW | "unsafe_raw" | FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_LOW, FILTER_FLAG_ENCODE_HIGH, FILTER_FLAG_ENCODE_AMP | 不做任何改变,或是按标志位去除或是编码指定字母。 | |
FILTER_CALLBACK | "callback" | FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_ENCODE_LOW, FILTER_FLAG_ENCODE_HIGH, FILTER_FLAG_ENCODE_AMP | 自定义过滤器 |
ID | 可用的过滤器 | 描述 |
---|---|---|
FILTER_FLAG_STRIP_LOW | FILTER_SANITIZE_ENCODED, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_SANITIZE_STRING, FILTER_UNSAFE_RAW | 去除ASCII小于32的字符。 |
FILTER_FLAG_STRIP_HIGH | FILTER_SANITIZE_ENCODED, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_SANITIZE_STRING, FILTER_UNSAFE_RAW | 去除ASCII在于127的字符。 |
FILTER_FLAG_ALLOW_FRACTION | FILTER_SANITIZE_NUMBER_FLOAT | 允许小数点分隔符(.) |
FILTER_FLAG_ALLOW_THOUSAND | FILTER_SANITIZE_NUMBER_FLOAT, FILTER_VALIDATE_FLOAT | 允许千位分隔符(,) |
FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_SANITIZE_NUMBER_FLOAT | 允许科学计数法(e或E)。 |
FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_SANITIZE_STRING | 不编码引号(单引号和双引号)。 |
FILTER_FLAG_ENCODE_LOW | FILTER_SANITIZE_ENCODED, FILTER_SANITIZE_STRING, FILTER_SANITIZE_RAW | 编码ASCII小于32的字符。 |
FILTER_FLAG_ENCODE_HIGH | FILTER_SANITIZE_ENCODED, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_SANITIZE_STRING, FILTER_SANITIZE_RAW | 编码ASCII大于127的字母。 |
FILTER_FLAG_ENCODE_AMP | FILTER_SANITIZE_STRING, FILTER_SANITIZE_RAW | 编码&符号。 |
FILTER_NULL_ON_FAILURE | FILTER_VALIDATE_BOOLEAN | 返回null当验证数据不是以下字符串时(yes,no,1,0,true,false,on,off)。 |
FILTER_FLAG_ALLOW_OCTAL | FILTER_VALIDATE_INT | 允许八进制数值(0开头)。 |
FILTER_FLAG_ALLOW_HEX | FILTER_VALIDATE_INT | 允许16进制数值。(0X或是0x开头)。 |
FILTER_FLAG_IPV4 | FILTER_VALIDATE_IP | IP4格式字符串。 |
FILTER_FLAG_IPV6 | FILTER_VALIDATE_IP | IP6格式字符串。 |
FILTER_FLAG_NO_PRIV_RANGE | FILTER_VALIDATE_IP | RFC指定的私域IP。IP4如下范围10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16。或是IP6以下开头的域: FD或FC |
FILTER_FLAG_NO_RES_RANGE | FILTER_VALIDATE_IP | 要求值不在保留的 IP 范围内。IPv4 ranges:0.0.0.0/8, 169.254.0.0/16,192.0.2.0/24 and 224.0.0.0/4。不能应用于IP6。 |
FILTER_FLAG_PATH_REQUIRED | FILTER_VALIDATE_URL | 要求URL包含路径部分。 |
FILTER_FLAG_QUERY_REQUIRED | FILTER_VALIDATE_URL | 要求URL查询字符串。 |