Filter flags
ID | Used with | Description |
---|---|---|
FILTER_FLAG_STRIP_LOW |
FILTER_SANITIZE_ENCODED ,
FILTER_SANITIZE_SPECIAL_CHARS ,
FILTER_SANITIZE_STRING ,
FILTER_UNSAFE_RAW
|
Strips characters that have a numerical value <32. |
FILTER_FLAG_STRIP_HIGH |
FILTER_SANITIZE_ENCODED ,
FILTER_SANITIZE_SPECIAL_CHARS ,
FILTER_SANITIZE_STRING ,
FILTER_UNSAFE_RAW
|
Strips characters that have a numerical value >127. |
FILTER_FLAG_STRIP_BACKTICK |
FILTER_SANITIZE_ENCODED ,
FILTER_SANITIZE_SPECIAL_CHARS ,
FILTER_SANITIZE_STRING ,
FILTER_UNSAFE_RAW
|
Strips backtick characters. |
FILTER_FLAG_ALLOW_FRACTION |
FILTER_SANITIZE_NUMBER_FLOAT
|
Allows a period (.) as a fractional separator in numbers. |
FILTER_FLAG_ALLOW_THOUSAND |
FILTER_SANITIZE_NUMBER_FLOAT ,
FILTER_VALIDATE_FLOAT
|
Allows a comma (,) as a thousands separator in numbers. |
FILTER_FLAG_ALLOW_SCIENTIFIC |
FILTER_SANITIZE_NUMBER_FLOAT
|
Allows an e or E for scientific notation in numbers. |
FILTER_FLAG_NO_ENCODE_QUOTES |
FILTER_SANITIZE_STRING
|
If this flag is present, single (') and double (") quotes will not be encoded. |
FILTER_FLAG_ENCODE_LOW |
FILTER_SANITIZE_ENCODED ,
FILTER_SANITIZE_STRING ,
FILTER_SANITIZE_RAW
|
Encodes all characters with a numerical value <32. |
FILTER_FLAG_ENCODE_HIGH |
FILTER_SANITIZE_ENCODED ,
FILTER_SANITIZE_SPECIAL_CHARS ,
FILTER_SANITIZE_STRING ,
FILTER_SANITIZE_RAW
|
Encodes all characters with a numerical value >127. |
FILTER_FLAG_ENCODE_AMP |
FILTER_SANITIZE_STRING ,
FILTER_SANITIZE_RAW
|
Encodes ampersands (&). |
FILTER_NULL_ON_FAILURE |
FILTER_VALIDATE_BOOLEAN
|
Returns NULL for unrecognized boolean values.
|
FILTER_FLAG_ALLOW_OCTAL |
FILTER_VALIDATE_INT
|
Regards inputs starting with a zero (0) as octal numbers. This only allows the succeeding digits to be 0-7. |
FILTER_FLAG_ALLOW_HEX |
FILTER_VALIDATE_INT
|
Regards inputs starting with 0x or 0X as hexadecimal numbers. This only allows succeeding characters to be a-fA-F0-9. |
FILTER_FLAG_EMAIL_UNICODE |
FILTER_VALIDATE_EMAIL
|
Allows the local part of the email address to contain Unicode characters. |
FILTER_FLAG_IPV4 |
FILTER_VALIDATE_IP
|
Allows the IP address to be in IPv4 format. |
FILTER_FLAG_IPV6 |
FILTER_VALIDATE_IP
|
Allows the IP address to be in IPv6 format. |
FILTER_FLAG_NO_PRIV_RANGE |
FILTER_VALIDATE_IP
|
Fails validation for the following private IPv4 ranges: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Fails validation for the IPv6 addresses starting with FD or FC. |
FILTER_FLAG_NO_RES_RANGE |
FILTER_VALIDATE_IP
|
Fails validation for the following reserved IPv4 ranges: 0.0.0.0/8, 169.254.0.0/16, 127.0.0.0/8 and 240.0.0.0/4. Fails validation for the following reserved IPv6 ranges: ::1/128, ::/128, ::ffff:0:0/96 and fe80::/10. |
FILTER_FLAG_SCHEME_REQUIRED |
FILTER_VALIDATE_URL
|
Requires the URL to contain a scheme part. |
FILTER_FLAG_HOST_REQUIRED |
FILTER_VALIDATE_URL
|
Requires the URL to contain a host part. |
FILTER_FLAG_PATH_REQUIRED |
FILTER_VALIDATE_URL
|
Requires the URL to contain a path part. |
FILTER_FLAG_QUERY_REQUIRED |
FILTER_VALIDATE_URL
|
Requires the URL to contain a query string. |
FILTER_REQUIRE_SCALAR |
Requires the value to be scalar. | |
FILTER_REQUIRE_ARRAY |
Requires the value to be an array. | |
FILTER_FORCE_ARRAY |
If the value is a scalar, it is treated as array with the scalar value as only element. |
Changelog
Version | Description |
---|---|
7.3.0 |
The explicit usage of FILTER_FLAG_SCHEME_REQUIRED
and FILTER_FLAG_HOST_REQUIRED has been deprecated.
|
7.1.0 |
FILTER_FLAG_EMAIL_UNICODE has been added.
|
5.3.2 |
FILTER_FLAG_STRIP_BACKTICK has been added.
|
5.2.10 |
FILTER_FLAG_NO_RES_RANGE supports also IPv6 addresses.
|
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-filter.filters.flags.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.