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 | 自定义过滤器 |