<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filter.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.filter-input.php',
    1 => 'filter_input',
    2 => 'Получает конкретную внешнюю переменную по имени и, если нужно, фильтрует значение переменной',
  ),
  'up' => 
  array (
    0 => 'ref.filter.php',
    1 => 'Функции фильтрации данных',
  ),
  'prev' => 
  array (
    0 => 'function.filter-id.php',
    1 => 'filter_id',
  ),
  'next' => 
  array (
    0 => 'function.filter-input-array.php',
    1 => 'filter_input_array',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/filter/functions/filter-input.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.filter-input" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">filter_input</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">filter_input</span> &mdash; <span class="dc-title">Получает конкретную внешнюю переменную по имени и, если нужно, фильтрует значение переменной</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.filter-input-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>filter_input</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$type</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$var_name</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$filter</code><span class="initializer"> = <strong><code><a href="filter.constants.php#constant.filter-default">FILTER_DEFAULT</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span><br>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>


 </div>

 <div class="refsect1 parameters" id="refsect1-function.filter-input-parameters">
  <h3 class="title">Список параметров</h3>
  <dl>
   
    <dt><code class="parameter">type</code></dt>
    <dd>
     <span class="simpara">
      Одна из констант <strong><code><a href="filter.constants.php#constant.input-post">INPUT_<span class="replaceable">*</span></a></code></strong>.
     </span>
     <div class="warning"><strong class="warning">Внимание</strong>
      <p class="simpara">
       Содержимое фильтруемых суперглобальных переменных – это исходное «сырое» содержимое,
       предоставленное <abbr title="Server Application Programming Interface">SAPI</abbr>, до внесения пользователем каких-либо изменений
       в суперглобальные переменные.
       Для фильтрации изменённого суперглобального содержимого
       используйте функцию <span class="function"><a href="function.filter-var.php" class="function">filter_var()</a></span>.
      </p>
     </div>
    </dd>
   
   
    <dt><code class="parameter">var_name</code></dt>
    <dd>
     <span class="simpara">
      Имя переменной для фильтрации внутри соответствующего типа (<code class="parameter">type</code>) суперглобальных переменных.
     </span>
    </dd>
   
   
    <dt><code class="parameter">filter</code></dt>
    <dd>
     <span class="simpara">
      Фильтр, который необходимо применить.
      Может быть фильтром проверки с помощью одной из констант <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_<span class="replaceable">*</span></a></code></strong>,
      фильтром очистки с помощью одной из констант <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_<span class="replaceable">*</span></a></code></strong>,
      <strong><code><a href="filter.constants.php#constant.filter-unsafe-raw">FILTER_UNSAFE_RAW</a></code></strong> или пользовательским фильтром с помощью константы <strong><code><a href="filter.constants.php#constant.filter-callback">FILTER_CALLBACK</a></code></strong>.
     </span>
     <blockquote class="note"><p><strong class="note">Замечание</strong>: 
      <span class="simpara">
       По умолчанию используется <strong><code><a href="filter.constants.php#constant.filter-default">FILTER_DEFAULT</a></code></strong>,
       который является псевдонимом <strong><code><a href="filter.constants.php#constant.filter-unsafe-raw">FILTER_UNSAFE_RAW</a></code></strong>.
       В результате по умолчанию фильтрация не производится.
      </span>
     </p></blockquote>
    </dd>
   
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <span class="simpara">
      Либо ассоциативный массив (<span class="type"><a href="language.types.array.php" class="type array">array</a></span>) опций,
      либо битовая маска констант флагов фильтра <strong><code><a href="filter.constants.php#constant.filter-flag-none">FILTER_FLAG_<span class="replaceable">*</span></a></code></strong>.
     </span>
     <span class="simpara">
      Если параметр <code class="parameter">filter</code> принимает опции,
      флаги могут быть предоставлены с помощью значения массива <code class="literal">&quot;flags&quot;</code>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.filter-input-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="simpara">
   В случае успешного выполнения функция возвращает отфильтрованную переменную.
   Если переменная не установлена, возвращается значение <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
   В случае возникновения ошибки возвращается значение <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>,
   только не используется флаг <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.null">null</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.filter-input-examples">
  <h3 class="title">Примеры</h3>
  <div class="example" id="example-1">
   <p><strong>Пример #1 Пример использования функции <span class="function"><strong>filter_input()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$search_html </span><span style="color: #007700">= </span><span style="color: #0000BB">filter_input</span><span style="color: #007700">(</span><span style="color: #0000BB">INPUT_GET</span><span style="color: #007700">, </span><span style="color: #DD0000">'search'</span><span style="color: #007700">, </span><span style="color: #0000BB">FILTER_SANITIZE_SPECIAL_CHARS</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$search_url </span><span style="color: #007700">= </span><span style="color: #0000BB">filter_input</span><span style="color: #007700">(</span><span style="color: #0000BB">INPUT_GET</span><span style="color: #007700">, </span><span style="color: #DD0000">'search'</span><span style="color: #007700">, </span><span style="color: #0000BB">FILTER_SANITIZE_ENCODED</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Вы искали </span><span style="color: #0000BB">$search_html</span><span style="color: #DD0000">.\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">"&lt;a href='?search=</span><span style="color: #0000BB">$search_url</span><span style="color: #DD0000">'&gt;Искать снова.&lt;/a&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   
<div class="example-contents"><p>
 Вывод приведённого примера будет похож на:
</p></div>

   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Вы искали Me &amp;#38; son.
&lt;a href=&#039;?search=Me%20%26%20son&#039;&gt;Искать снова.&lt;/a&gt;</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.filter-input-seealso">
  <h3 class="title">Смотрите также</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.filter-input-array.php" class="function" rel="rdfs-seeAlso">filter_input_array()</a> - Получает несколько переменных извне PHP и, при необходимости, фильтрует их</span></li>
   <li><span class="function"><a href="function.filter-var.php" class="function" rel="rdfs-seeAlso">filter_var()</a> - Фильтрует переменную</span></li>
   <li><span class="function"><a href="function.filter-var-array.php" class="function" rel="rdfs-seeAlso">filter_var_array()</a> - Принимает несколько переменных и, при необходимости, фильтрует их</span></li>
   <li>
    Фильтры проверки:
    <strong><code><a href="filter.constants.php#constant.filter-validate-bool">FILTER_VALIDATE_<span class="replaceable">*</span></a></code></strong>
   </li>
   <li>
    Фильтры очистки:
    <strong><code><a href="filter.constants.php#constant.filter-sanitize-string">FILTER_SANITIZE_<span class="replaceable">*</span></a></code></strong>
   </li>
  </ul>

 </div>


</div><?php manual_footer($setup); ?>