<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Filter flags</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="filter.filters.misc.html">Other filters</a></div> <div class="next" style="text-align: right; float: right;"><a href="filter.constants.html">Predefined Constants</a></div> <div class="up"><a href="filter.filters.html">Types of filters</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="filter.filters.flags" class="section"> <h2 class="title">Filter flags</h2> <p class="para"> <table class="doctable table"> <caption><strong>List of filter flags</strong></caption> <thead> <tr> <th>ID</th> <th>Used with</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td><strong><code>FILTER_FLAG_STRIP_LOW</code></strong></td> <td> <strong><code>FILTER_SANITIZE_ENCODED</code></strong>, <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>, <strong><code>FILTER_SANITIZE_STRING</code></strong>, <strong><code>FILTER_UNSAFE_RAW</code></strong> </td> <td> Strips characters that have a numerical value <32. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_STRIP_HIGH</code></strong></td> <td> <strong><code>FILTER_SANITIZE_ENCODED</code></strong>, <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>, <strong><code>FILTER_SANITIZE_STRING</code></strong>, <strong><code>FILTER_UNSAFE_RAW</code></strong> </td> <td> Strips characters that have a numerical value >127. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_STRIP_BACKTICK</code></strong></td> <td> <strong><code>FILTER_SANITIZE_ENCODED</code></strong>, <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>, <strong><code>FILTER_SANITIZE_STRING</code></strong>, <strong><code>FILTER_UNSAFE_RAW</code></strong> </td> <td> Strips backtick characters. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ALLOW_FRACTION</code></strong></td> <td> <strong><code>FILTER_SANITIZE_NUMBER_FLOAT</code></strong> </td> <td> Allows a period (<em>.</em>) as a fractional separator in numbers. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ALLOW_THOUSAND</code></strong></td> <td> <strong><code>FILTER_SANITIZE_NUMBER_FLOAT</code></strong>, <strong><code>FILTER_VALIDATE_FLOAT</code></strong> </td> <td> Allows a comma (<em>,</em>) as a thousands separator in numbers. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ALLOW_SCIENTIFIC</code></strong></td> <td> <strong><code>FILTER_SANITIZE_NUMBER_FLOAT</code></strong> </td> <td> Allows an <em>e</em> or <em>E</em> for scientific notation in numbers. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_NO_ENCODE_QUOTES</code></strong></td> <td> <strong><code>FILTER_SANITIZE_STRING</code></strong> </td> <td> If this flag is present, single (<em>'</em>) and double (<em>"</em>) quotes will not be encoded. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ENCODE_LOW</code></strong></td> <td> <strong><code>FILTER_SANITIZE_ENCODED</code></strong>, <strong><code>FILTER_SANITIZE_STRING</code></strong>, <strong><code>FILTER_SANITIZE_RAW</code></strong> </td> <td> Encodes all characters with a numerical value <32. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ENCODE_HIGH</code></strong></td> <td> <strong><code>FILTER_SANITIZE_ENCODED</code></strong>, <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>, <strong><code>FILTER_SANITIZE_STRING</code></strong>, <strong><code>FILTER_SANITIZE_RAW</code></strong> </td> <td> Encodes all characters with a numerical value >127. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ENCODE_AMP</code></strong></td> <td> <strong><code>FILTER_SANITIZE_STRING</code></strong>, <strong><code>FILTER_SANITIZE_RAW</code></strong> </td> <td> Encodes ampersands (<em>&</em>). </td> </tr> <tr> <td><strong><code>FILTER_NULL_ON_FAILURE</code></strong></td> <td> <strong><code>FILTER_VALIDATE_BOOLEAN</code></strong> </td> <td> Returns <strong><code>NULL</code></strong> for unrecognized boolean values. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ALLOW_OCTAL</code></strong></td> <td> <strong><code>FILTER_VALIDATE_INT</code></strong> </td> <td> Regards inputs starting with a zero (<em>0</em>) as octal numbers. This only allows the succeeding digits to be <em>0-7</em>. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_ALLOW_HEX</code></strong></td> <td> <strong><code>FILTER_VALIDATE_INT</code></strong> </td> <td> Regards inputs starting with <em>0x</em> or <em>0X</em> as hexadecimal numbers. This only allows succeeding characters to be <em>a-fA-F0-9</em>. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_EMAIL_UNICODE</code></strong></td> <td> <strong><code>FILTER_VALIDATE_EMAIL</code></strong> </td> <td> Allows the local part of the email address to contain Unicode characters. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_IPV4</code></strong></td> <td> <strong><code>FILTER_VALIDATE_IP</code></strong> </td> <td> Allows the IP address to be in IPv4 format. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_IPV6</code></strong></td> <td> <strong><code>FILTER_VALIDATE_IP</code></strong> </td> <td> Allows the IP address to be in IPv6 format. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_NO_PRIV_RANGE</code></strong></td> <td> <strong><code>FILTER_VALIDATE_IP</code></strong> </td> <td> <p class="para"> Fails validation for the following private IPv4 ranges: <em>10.0.0.0/8</em>, <em>172.16.0.0/12</em> and <em>192.168.0.0/16</em>. </p> <p class="para"> Fails validation for the IPv6 addresses starting with <em>FD</em> or <em>FC</em>. </p> </td> </tr> <tr> <td><strong><code>FILTER_FLAG_NO_RES_RANGE</code></strong></td> <td> <strong><code>FILTER_VALIDATE_IP</code></strong> </td> <td> <p class="para"> Fails validation for the following reserved IPv4 ranges: <em>0.0.0.0/8</em>, <em>169.254.0.0/16</em>, <em>127.0.0.0/8</em> and <em>240.0.0.0/4</em>. </p> <p class="para"> Fails validation for the following reserved IPv6 ranges: <em>::1/128</em>, <em>::/128</em>, <em>::ffff:0:0/96</em> and <em>fe80::/10</em>. </p> </td> </tr> <tr> <td><strong><code>FILTER_FLAG_SCHEME_REQUIRED</code></strong></td> <td> <strong><code>FILTER_VALIDATE_URL</code></strong> </td> <td> Requires the <acronym title="Uniform Resource Locator">URL</acronym> to contain a scheme part. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_HOST_REQUIRED</code></strong></td> <td> <strong><code>FILTER_VALIDATE_URL</code></strong> </td> <td> Requires the <acronym title="Uniform Resource Locator">URL</acronym> to contain a host part. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_PATH_REQUIRED</code></strong></td> <td> <strong><code>FILTER_VALIDATE_URL</code></strong> </td> <td> Requires the <acronym title="Uniform Resource Locator">URL</acronym> to contain a path part. </td> </tr> <tr> <td><strong><code>FILTER_FLAG_QUERY_REQUIRED</code></strong></td> <td> <strong><code>FILTER_VALIDATE_URL</code></strong> </td> <td> Requires the <acronym title="Uniform Resource Locator">URL</acronym> to contain a query string. </td> </tr> <tr> <td><strong><code>FILTER_REQUIRE_SCALAR</code></strong></td> <td> </td> <td> Requires the value to be scalar. </td> </tr> <tr> <td><strong><code>FILTER_REQUIRE_ARRAY</code></strong></td> <td> </td> <td> Requires the value to be an array. </td> </tr> <tr> <td><strong><code>FILTER_FORCE_ARRAY</code></strong></td> <td> </td> <td> If the value is a scalar, it is treated as array with the scalar value as only element. </td> </tr> </tbody> </table> </p> <div class="simplesect"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>7.3.0</td> <td> The explicit usage of <strong><code>FILTER_FLAG_SCHEME_REQUIRED</code></strong> and <strong><code>FILTER_FLAG_HOST_REQUIRED</code></strong> has been deprecated. </td> </tr> <tr> <td>7.1.0</td> <td> <strong><code>FILTER_FLAG_EMAIL_UNICODE</code></strong> has been added. </td> </tr> <tr> <td>5.3.2</td> <td> <strong><code>FILTER_FLAG_STRIP_BACKTICK</code></strong> has been added. </td> </tr> <tr> <td>5.2.10</td> <td> <strong><code>FILTER_FLAG_NO_RES_RANGE</code></strong> supports also IPv6 addresses. </td> </tr> </tbody> </table> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="filter.filters.misc.html">Other filters</a></div> <div class="next" style="text-align: right; float: right;"><a href="filter.constants.html">Predefined Constants</a></div> <div class="up"><a href="filter.filters.html">Types of filters</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>