<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'filter.constants.php',
    1 => '定義済み定数',
    2 => '定義済み定数',
  ),
  'up' => 
  array (
    0 => 'book.filter.php',
    1 => 'フィルタ',
  ),
  'prev' => 
  array (
    0 => 'filter.configuration.php',
    1 => '実行時設定',
  ),
  'next' => 
  array (
    0 => 'filter.examples.php',
    1 => '例',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    '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>
   </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>
   </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.false">false</a></code></strong> ではなく <strong><code><a href="reserved.constants.php#constant.null">null</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">
     <code class="literal">&quot;1&quot;</code>,
     2進数、8進数、16進数記法の <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>
     に対して、<strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> を返します。
    </span>
    <span class="simpara">
     <code class="literal">&quot;0&quot;</code>,
     2進数、8進数、16進数記法の <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> に対して、<strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
    </span>
    <span class="simpara">
     文字列の値は、大文字小文字の区別をせず比較されます。
     このフィルタが boolean 以外を返すかどうかは、
     <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> を返します。
     そうでない場合、<strong><code><a href="reserved.constants.php#constant.false">false</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">
        
        8 進表記 (<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">
        16 進表記 (<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>) を許可します。
        これは通常、1000ごとに桁を区切るのに使われます。
       </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">PCRE</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> に scheme 部分を必須とします。
       </span>
       <div class="warning"><strong class="warning">警告</strong>
        <p class="simpara">
         PHP 7.3.0 以降は<em>非推奨</em>になり、
         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> に host 部分を必須とします。
       </span>
       <div class="warning"><strong class="warning">警告</strong>
        <p class="simpara">
         PHP 7.3.0 以降は<em>非推奨</em>になり、
         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> に path 部分を必須とします。
       </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> に query 部分を必須とします。
       </span>
      </dd>
     
    </dl>
    <div class="warning"><strong class="warning">警告</strong>
     <p class="simpara">
      正しい <abbr title="Uniform Resource Locator">URL</abbr> であっても、
      <abbr title="Hypertext Transfer Protocol">HTTP</abbr> プロトコル (<code class="literal">http://</code>)
      を指定しない場合があります。
      よって、<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="American Standard Code for Information Interchange">ASCII</abbr> で構成された
      <abbr title="Uniform Resource Locator">URL</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">
     値が &quot;正しい&quot; メールアドレスかどうかを検証します。
    </span>

    <span class="simpara">
     <a href="https://datatracker.ietf.org/doc/html/rfc822" class="link external">&raquo;&nbsp;RFC 822</a>
     の <code class="literal">addr-spec</code> syntax に照らして検証は行われます。
     しかし、コメントやホワイトスペースのフォールディング、
     ドットなしのドメイン名はサポートされていません。
     よってこれらは拒否されます。
    </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">
        local の部分に Unicode を許可します。
        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">利用可能なオプション</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">
      PHP 8.1.0 以降は、このフィルタは <em>推奨されません</em>。
      代わりに、<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">
      PHP 8.1.0 以降は、このフィルタは <em>推奨されません</em>。
      代わりに、<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エンコードおよび、ASCII 値が32より小さい値をフィルタします。
     <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>
     <strong><code><a href="filter.constants.php#constant.filter-sanitize-full-special-chars">FILTER_SANITIZE_FULL_SPECIAL_CHARS</a></code></strong>
     と異なり、
     <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>
     フラグを無視します。
    </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>
     と一緒に使うことで、特殊文字を除去できます。
     そして、
     <strong><code><a href="filter.constants.php#constant.filter-flag-encode-high">FILTER_FLAG_ENCODE_HIGH</a></code></strong>
     と一緒に使うと、ASCII 値 127より大きな値をエンコードできます。
    </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>) を許可します。
        これは通常、1000ごとに桁を区切るのに使われます。
       </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> フラグを使わない場合、
      10進数のセパレータは削除され、変更された値を受け取ることになります。
     </p>
     <div class="informalexample">
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<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">));<br /></span><span style="color: #0000BB">?&gt;</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">
      PHP 7.3.0 以降は<em>非推奨</em>になり、
      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">
     このフィルタは、フィルタリング処理をユーザー定義の関数に委譲します。
     <code class="parameter">options</code> パラメータの <code class="literal">&#039;options&#039;</code>
     キー経由で <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> を渡します。
    </span>
    <p class="para">
     コールバックは、以下のシグネチャを持ちます:
     <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">
      コールバックから返される値が、
      フィルタ関数の呼び出しで返される値になります。
     </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 /></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">);<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="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); ?>