<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.filter-input.php',
    1 => 'filter_input',
    2 => '指定した名前の変数を外部から受け取り、オプションでそれをフィルタリングする',
  ),
  'up' => 
  array (
    0 => 'ref.filter.php',
    1 => 'Filter 関数',
  ),
  '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' => 'ja',
    '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> が提供する &quot;生の&quot; ものです。
       変更されたスーパーグローバルの値をフィルタするには、
       <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">
      オプションの連想配列。
      または、フラグ定数
      <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>、
   <code class="parameter">var_name</code> 変数が設定されていない場合は <strong><code><a href="reserved.constants.php#constant.null">null</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.false">false</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 />$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">"You have searched for </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;Search again.&lt;/a&gt;"</span><span style="color: #007700">;<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">You have searched for Me &amp;#38; son.
&lt;a href=&#039;?search=Me%20%26%20son&#039;&gt;Search again.&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> - 外部から変数を受け取り、オプションでそれらをフィルタリングする</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); ?>