<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/filter.constants.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'filter.constants.sanitization.php',
    1 => '除去フィルタ',
    2 => '除去フィルタ',
  ),
  'up' => 
  array (
    0 => 'filter.constants.php',
    1 => '定義済み定数',
  ),
  'prev' => 
  array (
    0 => 'filter.constants.validation.php',
    1 => '検証フィルタ',
  ),
  'next' => 
  array (
    0 => 'filter.constants.callback.php',
    1 => 'ユーザー定義のフィルタ',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/filter/constants.sanitization.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="filter.constants.sanitization" class="section">
 <h2 class="title">除去フィルタ</h2>
 <p class="simpara">
以下の定数が定義されています。
この関数の拡張モジュールが PHP 組み込みでコンパイルされているか、
実行時に動的にロードされている場合のみ使用可能です。
</p>
 <dl>
  
   <dt id="constant.filter-unsafe-raw">
    <strong><code><a href="filter.constants.sanitization.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>
    <p class="simpara">
     このフィルタは何もしません。
    </p>
    <p class="simpara">
     しかし、<strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>
     や <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-encode-low">FILTER_FLAG_ENCODE_<span class="replaceable">*</span></a></code></strong>
     と一緒に使うと、特殊な文字を除去したり、エンコードしたりできます。
    </p>
   </dd>
  
  
   <dt id="constant.filter-default">
    <strong><code><a href="filter.constants.sanitization.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>
    <p class="simpara">
     のエイリアス <strong><code><a href="filter.constants.sanitization.php#constant.filter-unsafe-raw">FILTER_UNSAFE_RAW</a></code></strong>.
    </p>
   </dd>
  
  
   <dt id="constant.filter-sanitize-string">
    <strong><code><a href="filter.constants.sanitization.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>
    <p class="simpara">
     このフィルタは、タグを除去したり、
     ダブルクォートやシングルクォートを HTML-エンコードしたりします。
    </p>
    <p class="simpara">
     フィルタ除去フラグ
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>,
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-encode-low">FILTER_FLAG_ENCODE_<span class="replaceable">*</span></a></code></strong>
     と一緒に使うことで、特殊文字を除去したり、エンコードしたりもできます。
    </p>
    <p class="simpara">
     クォートをエンコードする際の振る舞いは、
     フィルタフラグ <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-no-encode-quotes">FILTER_FLAG_NO_ENCODE_QUOTES</a></code></strong>
     を使うことで無効にできます。
    </p>
    <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.sanitization.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>
    <p class="simpara">
     のエイリアス <strong><code><a href="filter.constants.sanitization.php#constant.filter-sanitize-string">FILTER_SANITIZE_STRING</a></code></strong>.
    </p>
    <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.sanitization.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>
    <p class="simpara">
     このフィルタは、文字列をURLエンコードします。
    </p>
    <p class="simpara">
     このフィルタは、フィルタ除去フラグ
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>,
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-encode-low">FILTER_FLAG_ENCODE_<span class="replaceable">*</span></a></code></strong>
     と一緒に使うことで、特殊文字をエンコードしたり除去することができます。
    </p>
   </dd>
  
  
   <dt id="constant.filter-sanitize-special-chars">
    <strong><code><a href="filter.constants.sanitization.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">
     このフィルタは、
     <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より小さい文字をHTMLエンコードします。
     <strong><code><a href="filter.constants.sanitization.php#constant.filter-sanitize-full-special-chars">FILTER_SANITIZE_FULL_SPECIAL_CHARS</a></code></strong>
     と異なり、
     <strong><code><a href="filter.constants.sanitization.php#constant.filter-sanitize-special-chars">FILTER_SANITIZE_SPECIAL_CHARS</a></code></strong> 
     フィルタは
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-no-encode-quotes">FILTER_FLAG_NO_ENCODE_QUOTES</a></code></strong>
     フラグを無視します。
    </p>
    <p class="simpara">
     除去フラグ
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-strip-low">FILTER_FLAG_STRIP_<span class="replaceable">*</span></a></code></strong>
     と一緒に使うことで、特殊文字を除去できます。
     そして、
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-encode-high">FILTER_FLAG_ENCODE_HIGH</a></code></strong>
     と一緒に使うと、ASCII 値 127より大きな値をエンコードできます。
    </p>
   </dd>
  
  
   <dt id="constant.filter-sanitize-full-special-chars">
    <strong><code><a href="filter.constants.sanitization.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>
    <p 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>
     と一緒にコールした場合と同じです。
    </p>
    <p class="simpara">
     クォートをエンコードする際の振る舞いは、
     フィルタフラグ
     <strong><code><a href="filter.constants.flags.sanitization.php#constant.filter-flag-no-encode-quotes">FILTER_FLAG_NO_ENCODE_QUOTES</a></code></strong>
     を使うと無効にできます。
    </p>
    <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.sanitization.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>
    <p class="simpara">
     ラテン文字 (<code class="literal">[a-zA-Z]</code>),
     数字 (<code class="literal">[0-9]</code>),
     そして特殊文字
     <code class="literal">!#$%&amp;&#039;*+-=?^_`{|}~@.[]</code>
     以外の文字を全て除去します。
    </p>
   </dd>
  
  
   <dt id="constant.filter-sanitize-url">
    <strong><code><a href="filter.constants.sanitization.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>
    <p class="simpara">
     ラテン文字 (<code class="literal">[a-zA-Z]</code>),
     数字 (<code class="literal">[0-9]</code>),
     そして特殊文字
     <code class="literal">$-_.+!*&#039;(),{}|\\^~[]`&lt;&gt;#%&quot;;/?:@&amp;=</code>
     以外の文字を全て除去します。
    </p>
   </dd>
  
  
   <dt id="constant.filter-sanitize-number-int">
    <strong><code><a href="filter.constants.sanitization.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>
    <p class="simpara">
     数字 (<code class="literal">[0-9]</code>), プラス記号 (<code class="literal">+</code>),
     マイナス記号 (<code class="literal">-</code>) 以外の文字を全て除去します。
    </p>
   </dd>
  
  
   <dt id="constant.filter-sanitize-number-float">
    <strong><code><a href="filter.constants.sanitization.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>
    <p class="simpara">
     数字 (<code class="literal">[0-9]</code>), プラス記号 (<code class="literal">+</code>),
     マイナス記号 (<code class="literal">-</code>) 以外の文字を全て除去します。
    </p>

    <dl id="filter.constants.sanitization.float.flags">
     <strong class="title">オプションのフラグ</strong>
     
      <dt id="constant.filter-flag-allow-fraction">
       <strong><code><a href="filter.constants.sanitization.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>
       <p class="simpara">
        ドット文字 (<code class="literal">.</code>) を許可します。
        これは通常、整数部分と小数部分の区切りを表します。
       </p>
      </dd>
     
     
      <dt id="constant.filter-flag-allow-thousand">
       <strong><code><a href="filter.constants.sanitization.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>
       <p class="simpara">
        桁区切り文字 (<code class="literal">,</code>) を許可します。
        これは通常、1000ごとに桁を区切るのに使われます。
       </p>
      </dd>
     
     
      <dt id="constant.filter-flag-allow-scientific">
       <strong><code><a href="filter.constants.sanitization.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>
       <p class="simpara">
        <code class="literal">e</code> と <code class="literal">E</code> 文字を許可することで、
        科学的記法の数値を許可します。
       </p>
      </dd>
     
    </dl>
    <div class="warning"><strong class="warning">警告</strong>
     <p class="simpara">
      <strong><code><a href="filter.constants.sanitization.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"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
$number </span><span style="color: #007700">= </span><span style="color: #DD0000">'12.34'</span><span style="color: #007700">;

</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">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 style="color: #0000BB">?&gt;</span></code></pre></div>
      </div>

      <p class="simpara">上の例の出力は以下となります。</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.sanitization.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>
    <p class="simpara">
     入力に対して <span class="function"><a href="function.addslashes.php" class="function">addslashes()</a></span> を適用します。
     PHP 7.3.0 以降で利用可能です。
    </p>
   </dd>
  

  
   <dt id="constant.filter-sanitize-magic-quotes">
    <strong><code><a href="filter.constants.sanitization.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>
    <p class="simpara">
     のエイリアス <strong><code><a href="filter.constants.sanitization.php#constant.filter-sanitize-add-slashes">FILTER_SANITIZE_ADD_SLASHES</a></code></strong>.
    </p>
    <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>
</div><?php manual_footer($setup); ?>