<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.filter.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'filter.constants.php',
    1 => 'Предопределённые константы',
    2 => 'Предопределённые константы',
  ),
  'up' => 
  array (
    0 => 'book.filter.php',
    1 => 'Filter',
  ),
  'prev' => 
  array (
    0 => 'filter.configuration.php',
    1 => 'Настройка во время выполнения',
  ),
  'next' => 
  array (
    0 => 'filter.examples.php',
    1 => 'Примеры',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/filter/constants.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="filter.constants" class="appendix">
 <h1 class="title">Предопределённые константы</h1>

 
<p class="simpara">
 Следующие константы определяются модулем
 и доступны, только если модуль либо собрали в PHP,
 либо динамически загрузили при выполнении кода.
</p>

 <dl>
  <strong class="title">Константы входных данных</strong>
  <p class="simpara">
   Следующие константы указывают при вызове функций
   <span class="function"><a href="function.filter-input.php" class="function">filter_input()</a></span>
   и <span class="function"><a href="function.filter-input-array.php" class="function">filter_input_array()</a></span>.
  </p>
  
   <dt id="constant.input-post">
    <strong><code><a href="filter.constants.php#constant.input-post">INPUT_POST</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Переменные суперглобального массива <a href="reserved.variables.post.php" class="link">POST</a>.
    </span>
   </dd>
  
  
   <dt id="constant.input-get">
    <strong><code><a href="filter.constants.php#constant.input-get">INPUT_GET</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Переменные суперглобального массива <a href="reserved.variables.get.php" class="link">GET</a>.
    </span>
   </dd>
  
  
   <dt id="constant.input-cookie">
    <strong><code><a href="filter.constants.php#constant.input-cookie">INPUT_COOKIE</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Переменные суперглобального массива <a href="reserved.variables.cookies.php" class="link">COOKIE</a>.
    </span>
   </dd>
  
  
   <dt id="constant.input-env">
    <strong><code><a href="filter.constants.php#constant.input-env">INPUT_ENV</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Переменные суперглобального массива <a href="reserved.variables.environment.php" class="link">ENV</a>.
    </span>
   </dd>
  
  
   <dt id="constant.input-server">
    <strong><code><a href="filter.constants.php#constant.input-server">INPUT_SERVER</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Переменные суперглобального массива <a href="reserved.variables.server.php" class="link">SERVER</a>.
    </span>
   </dd>
  
  
   <dt id="constant.input-session">
    <strong><code><a href="filter.constants.php#constant.input-session">INPUT_SESSION</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Переменные суперглобального массива <a href="reserved.variables.session.php" class="link">SESSION</a>.
     Константу удалили с PHP 8.0.0; прежде константа оставалась в исходном коде, но не обрабатывалась функциями фильтрации.
    </span>
   </dd>
  
  
   <dt id="constant.input-request">
    <strong><code><a href="filter.constants.php#constant.input-request">INPUT_REQUEST</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Переменные <a href="reserved.variables.request.php" class="link">REQUEST</a>.
     Константу удалили с PHP 8.0.0; прежде константа оставалась в исходном коде, но не обрабатывалась функциями фильтрации.
    </span>
   </dd>
  
 </dl>

 <dl id="filter.constants.flags.generic">
  <strong class="title">Общие флаги фильтров</strong>
  
   <dt id="constant.filter-flag-none">
    <strong><code><a href="filter.constants.php#constant.filter-flag-none">FILTER_FLAG_NONE</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Не применять флаги.
    </span>
   </dd>
  
  
   <dt id="constant.filter-require-scalar">
    <strong><code><a href="filter.constants.php#constant.filter-require-scalar">FILTER_REQUIRE_SCALAR</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Проверять, принадлежит ли входное значение скалярному типу.
    </span>
   </dd>
  
  
   <dt id="constant.filter-require-array">
    <strong><code><a href="filter.constants.php#constant.filter-require-array">FILTER_REQUIRE_ARRAY</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Проверять, принадлежит ли входное значение типу <span class="type"><a href="language.types.array.php" class="type array">array</a></span>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-force-array">
    <strong><code><a href="filter.constants.php#constant.filter-force-array">FILTER_FORCE_ARRAY</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Оборачивать скалярные входные данные в одноэлементный массив (<span class="type"><a href="language.types.array.php" class="type array">array</a></span>)
     для фильтров, которые обрабатывают массивы.
    </span>
   </dd>
  
  
   <dt id="constant.filter-null-on-failure">
    <strong><code><a href="filter.constants.php#constant.filter-null-on-failure">FILTER_NULL_ON_FAILURE</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр возвращает <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> вместо <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, если значение не прошло проверку.
    </span>
    <span class="simpara">
     Флаг указывают при проверке значений фильтрами семейства
     <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_<span class="replaceable">*</span></a></code></strong>.
    </span>
   </dd>
  
 </dl>

 <dl id="filter.constants.flags.sanitization">
  <strong class="title">Флаги фильтров очистки</strong>
  
   <dt id="constant.filter-flag-strip-low">
    <strong><code><a href="filter.constants.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_LOW</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Удалять символы с ASCII-кодами меньше 32.
    </span>
   </dd>
  
  
   <dt id="constant.filter-flag-strip-high">
    <strong><code><a href="filter.constants.php#constant.filter-flag-strip-high">FILTER_FLAG_STRIP_HIGH</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Удалять символы с ASCII-кодами больше 127.
    </span>
   </dd>
  
  
   <dt id="constant.filter-flag-strip-backtick">
    <strong><code><a href="filter.constants.php#constant.filter-flag-strip-backtick">FILTER_FLAG_STRIP_BACKTICK</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Удалять символы обратной кавычки <code class="literal">`</code>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-flag-encode-low">
    <strong><code><a href="filter.constants.php#constant.filter-flag-encode-low">FILTER_FLAG_ENCODE_LOW</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Кодировать символы с ASCII-кодами меньше 32.
    </span>
   </dd>
  
  
   <dt id="constant.filter-flag-encode-high">
    <strong><code><a href="filter.constants.php#constant.filter-flag-encode-high">FILTER_FLAG_ENCODE_HIGH</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Кодировать символы с ASCII-кодами больше 127.
    </span>
   </dd>
  
  
   <dt id="constant.filter-flag-encode-amp">
    <strong><code><a href="filter.constants.php#constant.filter-flag-encode-amp">FILTER_FLAG_ENCODE_AMP</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Кодировать символ амперсанда <code class="literal">&amp;</code>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-flag-no-encode-quotes">
    <strong><code><a href="filter.constants.php#constant.filter-flag-no-encode-quotes">FILTER_FLAG_NO_ENCODE_QUOTES</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Отключить кодирование одинарных <code class="literal">&#039;</code> и двойных <code class="literal">&quot;</code>
     кавычек для отдельных фильтров.
    </span>
   </dd>
  
  
   <dt id="constant.filter-flag-empty-string-null">
    <strong><code><a href="filter.constants.php#constant.filter-flag-empty-string-null">FILTER_FLAG_EMPTY_STRING_NULL</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     
     Преобразовывать значение в <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>,
     если очистка строки возвращает пустую строку.
    </span>
   </dd>
  
 </dl>

 <dl id="filter.constants.validation">
  <strong class="title">Фильтры проверки данных</strong>

  
   <dt id="constant.filter-validate-bool">
    <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_BOOL</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр возвращает значение <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> для значений <code class="literal">&quot;1&quot;</code>,
     <code class="literal">1</code> (включая двоичную, восьмеричную и шестнадцатеричную нотации), <code class="literal">1.0</code>,
     <code class="literal">&quot;true&quot;</code>, <code class="literal">true</code>,
     <code class="literal">&quot;on&quot;</code>,
     и <code class="literal">&quot;yes&quot;</code>.
    </span>
    <span class="simpara">
     Фильтр возвращает значение <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> для значений <code class="literal">&quot;0&quot;</code>,
     <code class="literal">0</code> (включая двоичную, восьмеричную и шестнадцатеричную нотации), <code class="literal">0.0</code>,
     <code class="literal">&quot;false&quot;</code>, <code class="literal">false</code>,
     <code class="literal">&quot;off&quot;</code>,
     <code class="literal">&quot;no&quot;</code>
     и <code class="literal">&quot;&quot;</code>.
    </span>
    <span class="simpara">
     Строковые значения сравнивают без учёта регистра.
     С флагом <strong><code><a href="filter.constants.php#constant.filter-null-on-failure">FILTER_NULL_ON_FAILURE</a></code></strong> функция
     изменяет значение результата проверки нелогических значений.
     При установке флага вместо возврата значения <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> для нелогических значений функция возвращает значение <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
    </span>
    <dl id="filter.constants.validation.bool.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
       Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
    </dl>
    <span class="simpara">
     Фильтр доступен с PHP 8.0.0.
    </span>
   </dd>
  

  
   <dt id="constant.filter-validate-boolean">
    <strong><code><a href="filter.constants.php#constant.filter-validate-boolean">FILTER_VALIDATE_BOOLEAN</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Псевдоним фильтра <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_BOOL</a></code></strong>.
     До PHP 8.0.0 это название было каноническим названием фильтра проверки логических значений,
     а с появлением нового названия стало псевдонимом.
    </span>
   </dd>
  

  
   <dt id="constant.filter-validate-int">
    <strong><code><a href="filter.constants.php#constant.filter-validate-int">FILTER_VALIDATE_INT</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр проверяет, представляет ли значение целое число,
     и приводит значение к типу <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>, если значение прошло проверку.
    </span>

    <blockquote class="note"><p><strong class="note">Замечание</strong>: 
     <span class="simpara">
      Строковые значения обрезаются функцией <span class="function"><a href="function.trim.php" class="function">trim()</a></span>
      перед проверкой.
     </span>
    </p></blockquote>

    <dl id="filter.constants.validation.int.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
     
      <dt><code class="literal">min_range</code></dt>
      <dd>
       <span class="simpara">
        Значение пройдёт проверку, только если оно больше заданного значения или равно ему.
       </span>
      </dd>
     
     
      <dt><code class="literal">max_range</code></dt>
      <dd>
       <span class="simpara">
        Значение пройдёт проверку, только если оно меньше заданного значения или равно ему.
       </span>
      </dd>
     
    </dl>
    <dl id="filter.constants.validation.int.flags">
     <strong class="title">Дополнительные флаги</strong>
     
      <dt id="constant.filter-flag-allow-octal">
       <strong><code><a href="filter.constants.php#constant.filter-flag-allow-octal">FILTER_FLAG_ALLOW_OCTAL</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        
        Пропускает целочисленные значения в восьмеричной нотации,
        которая соответствует шаблону <code class="literal">0[0-7]+</code>.
       </span>
      </dd>
     
     
      <dt id="constant.filter-flag-allow-hex">
       <strong><code><a href="filter.constants.php#constant.filter-flag-allow-hex">FILTER_FLAG_ALLOW_HEX</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Пропускает целочисленные значения в шестнадцатеричной нотации,
        которая соответствует шаблону <code class="literal">0x[0-9a-fA-F]+</code>.
       </span>
      </dd>
     
    </dl>
   </dd>
  

  
   <dt id="constant.filter-validate-float">
    <strong><code><a href="filter.constants.php#constant.filter-validate-float">FILTER_VALIDATE_FLOAT</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр проверяет, представляет ли значение число с плавающей точкой,
     и приводит значение к типу <span class="type"><a href="language.types.float.php" class="type float">float</a></span>, если значение прошло проверку.
    </span>

    <blockquote class="note"><p><strong class="note">Замечание</strong>: 
     <span class="simpara">
      Строковые значения обрезаются функцией <span class="function"><a href="function.trim.php" class="function">trim()</a></span>
      перед проверкой.
     </span>
    </p></blockquote>

    <dl id="filter.constants.validation.float.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
     
      <dt><code class="literal">decimal</code></dt>
      <dd>
       <span class="simpara">
        
       </span>
      </dd>
     
     
      <dt><code class="literal">min_range</code></dt>
      <dd>
       <span class="simpara">
        Значение пройдёт проверку, только если оно больше заданного значения или равно ему.
        Опция доступна с PHP 7.4.0.
       </span>
      </dd>
     
     
      <dt><code class="literal">max_range</code></dt>
      <dd>
       <span class="simpara">
        Значение пройдёт проверку, только если оно меньше заданного значения или равно ему.
        Опция доступна с PHP 7.4.0.
       </span>
      </dd>
     
    </dl>
    <dl id="filter.constants.validation.float.flags">
     <strong class="title">Дополнительные флаги</strong>
     
      <dt>
       <strong><code><a href="filter.constants.php#constant.filter-flag-allow-thousand">FILTER_FLAG_ALLOW_THOUSAND</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Флаг разрешает фильтру пропускать значения с запятыми <code class="literal">,</code>,
        которыми часто отбивают тысячи.
       </span>
      </dd>
     
    </dl>
   </dd>
  
  
   <dt id="constant.filter-validate-regexp">
    <strong><code><a href="filter.constants.php#constant.filter-validate-regexp">FILTER_VALIDATE_REGEXP</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр проверяет, соответствует ли значение регулярному выражению,
     которое указали в опции <code class="literal">regexp</code>.
    </span>

    <dl id="filter.constants.validation.regex.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
     
      <dt><code class="literal">regexp</code></dt>
      <dd>
       <span class="simpara">
        <a href="book.pcre.php" class="link">Perl-совместимые</a> регулярные выражения.
       </span>
      </dd>
     
    </dl>
   </dd>
  

  
   <dt id="constant.filter-validate-url">
    <strong><code><a href="filter.constants.php#constant.filter-validate-url">FILTER_VALIDATE_URL</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр проверяет, соответствует ли <abbr title="Uniform Resource Locator">URL</abbr>-адрес стандарту
     <a href="https://datatracker.ietf.org/doc/html/rfc2396" class="link external">&raquo;&nbsp;RFC 2396</a>.
    </span>
    <dl id="filter.constants.validation.url.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
    </dl>
    <dl id="filter.constants.validation.url.flags">
     <strong class="title">Дополнительные флаги</strong>
     
      <dt id="constant.filter-flag-scheme-required">
       <strong><code><a href="filter.constants.php#constant.filter-flag-scheme-required">FILTER_FLAG_SCHEME_REQUIRED</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Проверять, содержит ли <abbr title="Uniform Resource Locator">URL</abbr>-адрес схему ресурса.
       </span>
       <div class="warning"><strong class="warning">Внимание</strong>
        <p class="simpara">
         Флаг <em>УСТАРЕЛ</em> с PHP 7.3.0,
         а с PHP 8.0.0 флаг <em>УДАЛИЛИ</em>,
         поскольку фильтр <strong><code><a href="filter.constants.php#constant.filter-validate-url">FILTER_VALIDATE_URL</a></code></strong>
         и без того проверяет, содержит ли адрес схему.
        </p>
       </div>
      </dd>
     
     
      <dt id="constant.filter-flag-host-required">
       <strong><code><a href="filter.constants.php#constant.filter-flag-host-required">FILTER_FLAG_HOST_REQUIRED</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Проверять, содержит ли <abbr title="Uniform Resource Locator">URL</abbr>-адрес хост.
       </span>
       <div class="warning"><strong class="warning">Внимание</strong>
        <p class="simpara">
         Флаг <em>УСТАРЕЛ</em> с PHP 7.3.0,
         а с PHP 8.0.0 флаг <em>УДАЛИЛИ</em>,
         поскольку фильтр <strong><code><a href="filter.constants.php#constant.filter-validate-url">FILTER_VALIDATE_URL</a></code></strong>
         и без того проверяет, содержит ли адрес хост.
        </p>
       </div>
      </dd>
     
     
      <dt id="constant.filter-flag-path-required">
       <strong><code><a href="filter.constants.php#constant.filter-flag-path-required">FILTER_FLAG_PATH_REQUIRED</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Проверять, содержит ли <abbr title="Uniform Resource Locator">URL</abbr>-адрес путь.
       </span>
      </dd>
     
     
      <dt id="constant.filter-flag-query-required">
       <strong><code><a href="filter.constants.php#constant.filter-flag-query-required">FILTER_FLAG_QUERY_REQUIRED</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Проверять, содержит ли <abbr title="Uniform Resource Locator">URL</abbr>-адрес аргументы запроса.
       </span>
      </dd>
     
    </dl>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      К допустимым <abbr title="Uniform Resource Locator">URL</abbr>-адресам относятся не только ресурсы
      со схемой <code class="literal">http://</code>, которая определяет <abbr title="Hypertext Transfer Protocol">HTTP</abbr>-протокол,
      поэтому иногда требуется дополнительная проверка, которая определит,
      содержит ли <abbr title="Uniform Resource Locator">URL</abbr>-адрес конкретный протокол
      наподобие <code class="literal">ssh://</code> или идентификатор схемы наподобие <code class="literal">mailto:</code>.
     </p>
    </div>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Фильтр проверяет только <abbr title="Uniform Resource Locator">URL</abbr>-адреса, которые состоят из <abbr title="American Standard Code for Information Interchange">ASCII</abbr>-символов,
      поэтому отклоняет международные доменные имена (англ. Internationalized Domain Names, IDN).
     </p>
    </div>
   </dd>
  
  
   <dt id="constant.filter-validate-domain">
    <strong><code><a href="filter.constants.php#constant.filter-validate-domain">FILTER_VALIDATE_DOMAIN</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр проверяет, соответствует ли доменное имя стандартам
     <a href="https://datatracker.ietf.org/doc/html/rfc952" class="link external">&raquo;&nbsp;RFC 952</a>,
     <a href="https://datatracker.ietf.org/doc/html/rfc1034" class="link external">&raquo;&nbsp;RFC 1034</a>,
     <a href="https://datatracker.ietf.org/doc/html/rfc1035" class="link external">&raquo;&nbsp;RFC 1035</a>,
     <a href="https://datatracker.ietf.org/doc/html/rfc1034" class="link external">&raquo;&nbsp;RFC 1123</a>,
     <a href="https://datatracker.ietf.org/doc/html/rfc1034" class="link external">&raquo;&nbsp;RFC 2732</a>
     и <a href="https://datatracker.ietf.org/doc/html/rfc2181" class="link external">&raquo;&nbsp;RFC 2181</a>.
    </span>
    <dl id="filter.constants.validation.domain.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
    </dl>
    <dl id="filter.constants.validation.domain.flags">
     <strong class="title">Дополнительные флаги</strong>
     
      <dt id="constant.filter-flag-hostname">
       <strong><code><a href="filter.constants.php#constant.filter-flag-hostname">FILTER_FLAG_HOSTNAME</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Проверять, начинается ли имя хоста с буквенно-цифрового символа
        и содержит только буквы, цифры или дефисы.
       </span>
      </dd>
     
    </dl>
   </dd>
  
  
   <dt id="constant.filter-validate-email">
    <strong><code><a href="filter.constants.php#constant.filter-validate-email">FILTER_VALIDATE_EMAIL</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр проверяет, «допустим» ли адрес эл. почты.
    </span>

    <span class="simpara">
     Фильтр проверяет, соответствует ли почтовый адрес синтаксису спецификации <code class="literal">addr-spec</code>
     по стандарту
     <a href="https://datatracker.ietf.org/doc/html/rfc822" class="link external">&raquo;&nbsp;RFC 822</a>.
     Фильтр не поддерживает комментарии, свёртывание пробельных символов и домены без точек,
     поэтому отклоняет такие адреса.
    </span>

    <dl id="filter.constants.validation.email.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
    </dl>
    <dl id="filter.constants.validation.email.flags">
     <strong class="title">Дополнительные флаги</strong>
     
      <dt id="constant.filter-flag-email-unicode">
       <strong><code><a href="filter.constants.php#constant.filter-flag-email-unicode">FILTER_FLAG_EMAIL_UNICODE</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Флаг разрешает фильтру принимать символы Юникода в локальной части адреса, которая идёт перед символом @.
        Флаг доступен с PHP 7.1.0.
       </span>
      </dd>
     
    </dl>

    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Проверка адреса эл. почты сложна, и единственный надёжный способ подтвердить
      корректность и доступность адреса — отправить электронное письмо адресату.
     </p>
    </div>
   </dd>
  

  
   <dt id="constant.filter-validate-ip">
    <strong><code><a href="filter.constants.php#constant.filter-validate-ip">FILTER_VALIDATE_IP</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <p class="para">
     Фильтр проверяет значение как IP-адрес.
    </p>
    <dl id="filter.constants.validation.ip.options">
     <strong class="title">Available options</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
    </dl>
    <dl id="filter.constants.validation.ip.flags">
     <strong class="title">Дополнительные флаги</strong>
     
      <dt id="constant.filter-flag-ipv4">
       <strong><code><a href="filter.constants.php#constant.filter-flag-ipv4">FILTER_FLAG_IPV4</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Разрешает IPv4-адреса.
       </span>
      </dd>
     
     
      <dt id="constant.filter-flag-ipv6">
       <strong><code><a href="filter.constants.php#constant.filter-flag-ipv6">FILTER_FLAG_IPV6</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Разрешает IPv6-адреса.
       </span>
      </dd>
     
     
      <dt id="constant.filter-flag-no-res-range">
       <strong><code><a href="filter.constants.php#constant.filter-flag-no-res-range">FILTER_FLAG_NO_RES_RANGE</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Запрещает зарезервированные адреса.
       </span>
       <span class="simpara">
        К зарезервированным относятся адреса диапазонов, которые
        в стандарте <a href="https://datatracker.ietf.org/doc/html/rfc6890" class="link external">&raquo;&nbsp;RFC 6890</a>
        пометили атрибутом <code class="literal">Reserved-By-Protocol</code>.
       </span>
       <p class="para">
        Зарезервированные IPv4-адреса соответствуют следующим диапазонам:
        <span class="simplelist"><code class="literal">0.0.0.0/8</code>, <code class="literal">169.254.0.0/16</code>, <code class="literal">127.0.0.0/8</code>, <code class="literal">240.0.0.0/4</code></span>.
       </p>
       <p class="para">
        Зарезервированные IPv6-адреса соответствуют следующим диапазонам:
        <span class="simplelist"><code class="literal">::1/128</code>, <code class="literal">::/128</code>, <code class="literal">::FFFF:0:0/96</code>, <code class="literal">FE80::/10</code></span>.
       </p>
      </dd>
     
     
      <dt id="constant.filter-flag-no-priv-range">
       <strong><code><a href="filter.constants.php#constant.filter-flag-no-priv-range">FILTER_FLAG_NO_PRIV_RANGE</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Запрещает частные адреса.
       </span>
       <p class="para">
        К частным относятся IPv4-адреса в следующих диапазонах:
        <span class="simplelist"><code class="literal">10.0.0.0/8</code>, <code class="literal">172.16.0.0/12</code>, <code class="literal">192.168.0.0/16</code></span>.
       </p>
       <span class="simpara">
        К частным относятся IPv6-адреса, которые начинаются
        на <code class="literal">FD</code> или <code class="literal">FC</code>.
       </span>
      </dd>
     
     
      <dt id="constant.filter-flag-global-range">
       <strong><code><a href="filter.constants.php#constant.filter-flag-global-range">FILTER_FLAG_GLOBAL_RANGE</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Разрешает только глобальные адреса.
        Для глобальных адресов стандарт
        <a href="https://datatracker.ietf.org/doc/html/rfc6890" class="link external">&raquo;&nbsp;RFC 6890</a> устанавливает
        в атрибуте <code class="literal">Global</code> значение <code class="literal">True</code>.
        Флаг доступен с PHP 8.2.0.
       </span>
      </dd>
     
    </dl>
   </dd>
  

  
   <dt id="constant.filter-validate-mac">
    <strong><code><a href="filter.constants.php#constant.filter-validate-mac">FILTER_VALIDATE_MAC</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр проверяет, соответствует ли значение MAC-адресу.
    </span>

    <dl id="filter.constants.validation.mac.options">
     <strong class="title">Доступные опции</strong>
     
      <dt><code class="literal">default</code></dt>
      <dd>
       <span class="simpara">
        Значение, которое вернёт фильтр, если входные данные не пройдут проверку.
       </span>
      </dd>
     
    </dl>
   </dd>
  
 </dl>

 <dl id="filter.constants.sanitization">
  <strong class="title">Фильтры очистки</strong>
  
   <dt id="constant.filter-unsafe-raw">
    <strong><code><a href="filter.constants.php#constant.filter-unsafe-raw">FILTER_UNSAFE_RAW</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр ничего не проверяет.
    </span>
    <span class="simpara">
     При этом фильтр удалит или закодирует спецсимволы, если работает
     совместно с флагами очистки из семейства <strong><code><a href="filter.constants.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>
     или <strong><code><a href="filter.constants.php#constant.filter-flag-encode-low">FILTER_FLAG_ENCODE_<span class="replaceable">*</span></a></code></strong>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-default">
    <strong><code><a href="filter.constants.php#constant.filter-default">FILTER_DEFAULT</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Псевдоним фильтра <strong><code><a href="filter.constants.php#constant.filter-unsafe-raw">FILTER_UNSAFE_RAW</a></code></strong>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-sanitize-string">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_STRING</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр удаляет теги и кодирует двойные и одинарные кавычки в числовые HTML-сущности.
    </span>
    <span class="simpara">
     Фильтр дополнительно удалит или закодирует символы, если работает
     совместно с флагами очистки из семейства <strong><code><a href="filter.constants.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>
     или <strong><code><a href="filter.constants.php#constant.filter-flag-encode-low">FILTER_FLAG_ENCODE_<span class="replaceable">*</span></a></code></strong>.
    </span>
    <span class="simpara">
     Флаг <strong><code><a href="filter.constants.php#constant.filter-flag-no-encode-quotes">FILTER_FLAG_NO_ENCODE_QUOTES</a></code></strong>
     отключает кодирование кавычек.
    </span>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Фильтр <em>устарел</em> с PHP 8.1.0,
      вместо него спецсимволы преобразовывают функцией <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>.
     </p>
    </div>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Фильтр и функция
      <span class="function"><a href="function.strip-tags.php" class="function">strip_tags()</a></span> удаляют теги по-разному.
     </p>
    </div>
   </dd>
  
  
   <dt id="constant.filter-sanitize-stripped">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-stripped">FILTER_SANITIZE_STRIPPED</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Псевдоним фильтра <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_STRING</a></code></strong>.
    </span>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Фильтр <em>устарел</em> с PHP 8.1.0,
      вместо него спецсимволы преобразовывают функцией <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>.
     </p>
    </div>
   </dd>
  
  
   <dt id="constant.filter-sanitize-encoded">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-encoded">FILTER_SANITIZE_ENCODED</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр кодирует строку для безопасного включения в состав URL-адреса.
    </span>
    <span class="simpara">
     Фильтр дополнительно удалит или закодирует символы, если работает
     совместно с флагами очистки из семейства <strong><code><a href="filter.constants.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>
     или <strong><code><a href="filter.constants.php#constant.filter-flag-encode-low">FILTER_FLAG_ENCODE_<span class="replaceable">*</span></a></code></strong>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-sanitize-special-chars">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-special-chars">FILTER_SANITIZE_SPECIAL_CHARS</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <p class="para">
     Фильтр преобразовывает в числовые HTML-сущности символы
     <span class="simplelist"><code class="literal">&#039;</code>, <code class="literal">&quot;</code>, <code class="literal">&lt;</code>, <code class="literal">&gt;</code>, <code class="literal">&amp;</code></span>
     и символы с ASCII-кодами меньше 32.
     Фильтр <strong><code><a href="filter.constants.php#constant.filter-sanitize-special-chars">FILTER_SANITIZE_SPECIAL_CHARS</a></code></strong> игнорирует
     флаг <strong><code><a href="filter.constants.php#constant.filter-flag-no-encode-quotes">FILTER_FLAG_NO_ENCODE_QUOTES</a></code></strong>,
     в отличие от фильтра <strong><code><a href="filter.constants.php#constant.filter-sanitize-full-special-chars">FILTER_SANITIZE_FULL_SPECIAL_CHARS</a></code></strong>.
    </p>
    <span class="simpara">
     Фильтр дополнительно удалит символы, если работает
     совместно с флагами очистки из семейства <strong><code><a href="filter.constants.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>,
     и закодирует символы с ASCII-кодами
     больше 127 при установке флага <strong><code><a href="filter.constants.php#constant.filter-flag-encode-high">FILTER_FLAG_ENCODE_HIGH</a></code></strong>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-sanitize-full-special-chars">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-full-special-chars">FILTER_SANITIZE_FULL_SPECIAL_CHARS</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Поведение фильтра аналогично вызову функции <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>
     с флагом <strong><code><a href="string.constants.php#constant.ent-quotes">ENT_QUOTES</a></code></strong>.
    </span>
    <span class="simpara">
     Флаг <strong><code><a href="filter.constants.php#constant.filter-flag-no-encode-quotes">FILTER_FLAG_NO_ENCODE_QUOTES</a></code></strong>
     отключает кодирование кавычек.
    </span>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Аналогично функции <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span> фильтр учитывает
      настройку INI-директивы <a href="ini.core.php#ini.default-charset" class="link">default_charset</a>.
      Входная строка отклоняется, и фильтр возвращает пустую строку,
      если последовательность байтов невозможно декодировать в допустимый символ
      в текущем наборе символов.
     </p>
    </div>
   </dd>
  
  
   <dt id="constant.filter-sanitize-email">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-email">FILTER_SANITIZE_EMAIL</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр очищает строку путём удаления всех символов,
     кроме латинских букв, которые соответствуют шаблону <code class="literal">[a-zA-Z]</code>,
     цифр, которые совпадают с шаблоном <code class="literal">[0-9]</code>,
     и спецсимволов
     <code class="literal">!#$%&amp;&#039;*+-=?^_`{|}~@.[]</code>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-sanitize-url">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-url">FILTER_SANITIZE_URL</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр очищает строку путём удаления всех символов,
     кроме латинских букв, которые соответствуют шаблону <code class="literal">[a-zA-Z]</code>,
     цифр, которые совпадают с шаблоном <code class="literal">[0-9]</code>,
     и спецсимволов
     <code class="literal">$-_.+!*&#039;(),{}|\\^~[]`&lt;&gt;#%&quot;;/?:@&amp;=</code>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-sanitize-number-int">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-number-int">FILTER_SANITIZE_NUMBER_INT</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр очищает строку путём удаления всех символов,
     кроме цифр, которые соответствуют шаблону <code class="literal">[0-9]</code>, знаков сложения и вычитания:
     <code class="literal">+</code> и <code class="literal">-</code>.
    </span>
   </dd>
  
  
   <dt id="constant.filter-sanitize-number-float">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-number-float">FILTER_SANITIZE_NUMBER_FLOAT</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр очищает строку путём удаления всех символов,
     кроме цифр, которые соответствуют шаблону <code class="literal">[0-9]</code>, знаков сложения и вычитания:
     <code class="literal">+</code> и <code class="literal">-</code>.
    </span>

    <dl id="filter.constants.sanitization.float.flags">
     <strong class="title">Дополнительные флаги</strong>
     
      <dt id="constant.filter-flag-allow-fraction">
       <strong><code><a href="filter.constants.php#constant.filter-flag-allow-fraction">FILTER_FLAG_ALLOW_FRACTION</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Флаг разрешает фильтру пропускать символ <code class="literal">.</code>
        как стандартный разделитель целой
        и дробной частей.
       </span>
      </dd>
     
     
      <dt id="constant.filter-flag-allow-thousand">
       <strong><code><a href="filter.constants.php#constant.filter-flag-allow-thousand">FILTER_FLAG_ALLOW_THOUSAND</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Флаг разрешает фильтру пропускать символ <code class="literal">,</code>
        как стандартный разделитель тысяч.
       </span>
      </dd>
     
     
      <dt id="constant.filter-flag-allow-scientific">
       <strong><code><a href="filter.constants.php#constant.filter-flag-allow-scientific">FILTER_FLAG_ALLOW_SCIENTIFIC</a></code></strong>
       (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
      </dt>
      <dd>
       <span class="simpara">
        Пропускает числа в научной нотации
        с символами <code class="literal">e</code> и <code class="literal">E</code>.
       </span>
      </dd>
     
    </dl>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Без флага <strong><code><a href="filter.constants.php#constant.filter-flag-allow-fraction">FILTER_FLAG_ALLOW_FRACTION</a></code></strong>
      фильтр удаляет десятичный разделитель, чем изменяет входное значение.
     </p>
     <div class="informalexample">
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$number </span><span style="color: #007700">= </span><span style="color: #DD0000">'12.34'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">filter_var</span><span style="color: #007700">(</span><span style="color: #0000BB">$number</span><span style="color: #007700">, </span><span style="color: #0000BB">FILTER_SANITIZE_NUMBER_FLOAT</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">filter_var</span><span style="color: #007700">(</span><span style="color: #0000BB">$number</span><span style="color: #007700">, </span><span style="color: #0000BB">FILTER_SANITIZE_NUMBER_FLOAT</span><span style="color: #007700">, </span><span style="color: #0000BB">FILTER_FLAG_ALLOW_FRACTION</span><span style="color: #007700">));</span></span></code></div>
      </div>

      
<p class="para">
 Результат выполнения приведённого примера:
</p>

      <div class="example-contents screen">
<div class="cdata"><pre>
string(4) &quot;1234&quot;
string(5) &quot;12.34&quot;
</pre></div>
      </div>
     </div>
    </div>
   </dd>
  

  
   <dt id="constant.filter-sanitize-add-slashes">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-add-slashes">FILTER_SANITIZE_ADD_SLASHES</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр применяет функцию <span class="function"><a href="function.addslashes.php" class="function">addslashes()</a></span> ко входным данным.
     Фильтр доступен с PHP 7.3.0.
    </span>
   </dd>
  

  
   <dt id="constant.filter-sanitize-magic-quotes">
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-magic-quotes">FILTER_SANITIZE_MAGIC_QUOTES</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Псевдоним фильтра <strong><code><a href="filter.constants.php#constant.filter-sanitize-add-slashes">FILTER_SANITIZE_ADD_SLASHES</a></code></strong>.
    </span>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Фильтр <em>УСТАРЕЛ</em> с PHP 7.3.0,
      а с PHP 8.0.0 фильтр <em>УДАЛИЛИ</em>.
     </p>
    </div>
   </dd>
  
 </dl>

 <dl>
  <strong class="title">Пользовательский фильтр</strong>
  
   <dt id="constant.filter-callback">
    <strong><code><a href="filter.constants.php#constant.filter-callback">FILTER_CALLBACK</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Фильтр делегирует фильтрацию пользовательской функции.
     Выражение <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> передаётся
     через параметр <code class="parameter">options</code> как значение, связанное
     с ключом <code class="literal">&#039;options&#039;</code>.
    </span>
    <p class="para">
     Сигнатура callback-функции:
     <div class="methodsynopsis dc-description">
      <span class="methodname"><span class="replaceable">callback</span></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

     <dl>
      
       <dt><code class="parameter">value</code></dt>
       <dd>
        <span class="simpara">
         Значение для фильтрации.
        </span>
       </dd>
      
     </dl>
    </p>
    <blockquote class="note"><p><strong class="note">Замечание</strong>: 
     <span class="simpara">
      Значение возврата callback-функции вернётся
      как значение возврата из функции фильтрации.
     </span>
    </p></blockquote>
    <div class="example" id="example-1">
     <p><strong>Пример #1 
      Пример проверки имени пользователя фильтром <strong><code><a href="filter.constants.php#constant.filter-callback">FILTER_CALLBACK</a></code></strong>
     </strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">function </span><span style="color: #0000BB">validate_login</span><span style="color: #007700">(</span><span style="color: #0000BB">string $value</span><span style="color: #007700">): ?</span><span style="color: #0000BB">string<br /></span><span style="color: #007700">{<br />    if (</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$value</span><span style="color: #007700">) &gt;= </span><span style="color: #0000BB">5 </span><span style="color: #007700">&amp;&amp; </span><span style="color: #0000BB">ctype_alnum</span><span style="color: #007700">(</span><span style="color: #0000BB">$value</span><span style="color: #007700">)) {<br />        return </span><span style="color: #0000BB">$value</span><span style="color: #007700">;<br />    }<br />    return </span><span style="color: #0000BB">null</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$login </span><span style="color: #007700">= </span><span style="color: #DD0000">"val1dL0gin"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$filtered_login </span><span style="color: #007700">= </span><span style="color: #0000BB">filter_var</span><span style="color: #007700">(</span><span style="color: #0000BB">$login</span><span style="color: #007700">, </span><span style="color: #0000BB">FILTER_CALLBACK</span><span style="color: #007700">, [</span><span style="color: #DD0000">'options' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'validate_login'</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$filtered_login</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$login </span><span style="color: #007700">= </span><span style="color: #DD0000">"f&amp;ke login"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$filtered_login </span><span style="color: #007700">= </span><span style="color: #0000BB">filter_var</span><span style="color: #007700">(</span><span style="color: #0000BB">$login</span><span style="color: #007700">, </span><span style="color: #0000BB">FILTER_CALLBACK</span><span style="color: #007700">, [</span><span style="color: #DD0000">'options' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'validate_login'</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$filtered_login</span><span style="color: #007700">);</span></span></code></div>
     </div>

     
<div class="example-contents"><p>
 Результат выполнения приведённого примера:
</p></div>

     <div class="example-contents screen">
<div class="cdata"><pre>
string(10) &quot;val1dL0gin&quot;
NULL
</pre></div>
     </div>
    </div>
    <div class="warning"><strong class="warning">Внимание</strong>
     <p class="simpara">
      Фильтр нельзя комбинировать с флагами,
      включая флаг <strong><code><a href="filter.constants.php#constant.filter-null-on-failure">FILTER_NULL_ON_FAILURE</a></code></strong>.
     </p>
    </div>
   </dd>
  
 </dl>
</div>
<?php manual_footer($setup); ?>