<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.filter-input-array.php',
    1 => 'filter_input_array',
    2 => '获取一系列外部变量，并且可以通过过滤器处理它们',
  ),
  'up' => 
  array (
    0 => 'ref.filter.php',
    1 => '过滤器函数',
  ),
  'prev' => 
  array (
    0 => 'function.filter-input.php',
    1 => 'filter_input',
  ),
  'next' => 
  array (
    0 => 'function.filter-list.php',
    1 => 'filter_list',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/filter/functions/filter-input-array.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.filter-input-array" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">filter_input_array</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">filter_input_array</span> &mdash; <span class="dc-title">获取一系列外部变量，并且可以通过过滤器处理它们</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.filter-input-array-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>filter_input_array</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$type</code></span>, <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"> = <strong><code><a href="filter.constants.php#constant.filter-default">FILTER_DEFAULT</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$add_empty</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>): <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.singleton.php" class="type false">false</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span></div>

  <p class="para rdfs-comment">
   这个函数当需要获取很多变量却不想重复调用<span class="function"><a href="function.filter-input.php" class="function">filter_input()</a></span>时很有用。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.filter-input-array-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-array.php" class="function">filter_var_array()</a></span>。
      </p>
     </div>
    </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-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> 常量的清理过滤器。
     </span>
     <span class="simpara">
      选项数组是关联数组，其中 key 对应于数据 <code class="parameter">array</code> 中的键，而关联的值要么是应用于该条目的过滤器，要么是描述如何以及应用哪个过滤器到该条目的关联数组。
     </span>
     <span class="simpara">
      描述如何应用过滤器的关联数组必须包含 <code class="literal">&#039;filter&#039;</code>
      key，其关联的值是要应用的过滤器，<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> 常量之一。还可以选择性地包含 <code class="literal">&#039;flags&#039;</code> key，用于指定适用于过滤器的
      flag，以及 <code class="literal">&#039;options&#039;</code> key，用于指定适用于过滤器的任何选项。
     </span>
    </dd>
   
   
    <dt><code class="parameter">add_empty</code></dt>
    <dd>
     <p class="para">
      为缺失的 key 添加 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> 到返回值中。
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.filter-input-array-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   成功时，返回 <span class="type"><a href="language.types.array.php" class="type array">array</a></span>，包含所请求变量的值。
  </p>
  <p class="simpara">
   失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。有一个失败的例外情况，就是 <code class="parameter">type</code> 指定的输入数组没有填充，并且使用了
   <strong><code><a href="filter.constants.php#constant.filter-null-on-failure">FILTER_NULL_ON_FAILURE</a></code></strong> flag 时，返回 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>。
  </p>
  <p class="simpara">
   如果 <code class="parameter">add_empty</code> 为 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>，则输入数组中缺失的条目会填充到返回数组中，并且缺失的条目将设置为
   <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>。
  </p>
  <p class="simpara">
   如果过滤失败，则返回 <span class="type"><a href="language.types.array.php" class="type array">array</a></span> 中的条目将为 <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> flag 时为 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.filter-input-array-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    在 <strong><code><a href="filter.constants.php#constant.input-server">INPUT_SERVER</a></code></strong> 数组中并没有 <code class="literal">REQUEST_TIME</code> ，因为它是被稍后插入到 <var class="varname"><a href="reserved.variables.server.php" class="classname">$_SERVER</a></var> 中的。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.filter-input-array-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.filter-input.php" class="function" rel="rdfs-seeAlso">filter_input()</a> - 通过名称获取特定的外部变量，并且可以通过过滤器处理它</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); ?>