<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.stream.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.stream-filter-prepend.php',
    1 => 'stream_filter_prepend',
    2 => 'フィルタをストリームに付加する',
  ),
  'up' => 
  array (
    0 => 'ref.stream.php',
    1 => 'ストリーム 関数',
  ),
  'prev' => 
  array (
    0 => 'function.stream-filter-append.php',
    1 => 'stream_filter_append',
  ),
  'next' => 
  array (
    0 => 'function.stream-filter-register.php',
    1 => 'stream_filter_register',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/stream/functions/stream-filter-prepend.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stream-filter-prepend" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_filter_prepend</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_filter_prepend</span> &mdash; <span class="dc-title">フィルタをストリームに付加する</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-filter-prepend-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_filter_prepend</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$stream</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">$filter_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">$mode</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$params</code><span class="initializer"> = ?</span></span><br>): <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></div>

  <p class="para rdfs-comment">
   <code class="parameter">filter_name</code> で指定されたフィルタを、
   <code class="parameter">stream</code> に付加されているフィルタのリストに加えます。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-filter-prepend-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stream</code></dt>
     <dd>
      <p class="para">
       対象となるストリーム。
      </p>
     </dd>
    
    
     <dt><code class="parameter">filter_name</code></dt>
     <dd>
      <p class="para">
       フィルタ名。
      </p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       デフォルトでは、 <span class="function"><strong>stream_filter_prepend()</strong></span> は
       ストリームが読み込み用に開かれている場合は (つまり、オープンモードが
       <code class="literal">r</code> あるいは <code class="literal">+</code> を伴う場合は)、
       フィルタを <code class="literal">リードフィルタチェイン</code> に追加し、
       ストリームが書き出し用に開かれている場合は(つまり、オープンモードが
       <code class="literal">w</code> か <code class="literal">a</code>か、あるいは<code class="literal">+</code> を伴う場合は)、
       <code class="literal">ライトフィルターチェィン</code>にも追加します。
       <strong><code><a href="stream.constants.php#constant.stream-filter-read">STREAM_FILTER_READ</a></code></strong>・
       <strong><code><a href="stream.constants.php#constant.stream-filter-write">STREAM_FILTER_WRITE</a></code></strong>・
       <strong><code><a href="stream.constants.php#constant.stream-filter-all">STREAM_FILTER_ALL</a></code></strong> を <code class="parameter">mode</code>パラメータに渡すことで、この挙動を変えることができます。
       このパラメータを使った例については、
       <span class="function"><a href="function.stream-filter-append.php" class="function">stream_filter_append()</a></span> を参照ください。
      </p>
     </dd>
    
    
     <dt><code class="parameter">params</code></dt>
     <dd>
      <p class="para">
       このフィルタは、指定された <code class="parameter">params</code> と共に、
       リストの<em>先頭</em>に追加され、ストリームに対する操作の中で最初に呼び出されます。
       フィルタをリストの末尾に加えたいときは、<span class="function"><a href="function.stream-filter-append.php" class="function">stream_filter_append()</a></span>
       を使ってください。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-filter-prepend-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   成功した場合にリソース、失敗した場合に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
   このリソースは、<span class="function"><a href="function.stream-filter-remove.php" class="function">stream_filter_remove()</a></span>
   をコールする際にこのフィルタインスタンスを参照するために使用可能です。
  </p>

  <p class="para">
   <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> が返されるのは、<code class="parameter">stream</code> がリソースではない場合や
   <code class="parameter">filter_name</code> が見つからない場合です。
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-filter-prepend-notes">
  <h3 class="title">注意</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <strong>カスタム(ユーザー)フィルタを使うには</strong><br />
   <span class="simpara">
    カスタムフィルタを <code class="parameter">filter_name</code> に指定するためには、
    まず <span class="function"><a href="function.stream-filter-register.php" class="function">stream_filter_register()</a></span> 関数でそれを登録しておく
    必要があります。
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    ストリームデータは（ローカルおよびリモートの）リソースからチャンク単位で
    読み込まれ、内部バッファに保持されます。新しいフィルタがストリームに
    追加されても、内部バッファにあるデータのうち既に他のフィルタの処理が
    終わっているものは新しいフィルタでは<em>処理されません</em>。
    これは <span class="function"><strong>stream_filter_apppend()</strong></span> の挙動とは違います。
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    フィルタが読み込み用および書き込み用に追加されると、フィルタのインスタンスが
    2 つ作成されます。両方のフィルタリソースを取得するには、
    <strong><code><a href="stream.constants.php#constant.stream-filter-read">STREAM_FILTER_READ</a></code></strong> と
    <strong><code><a href="stream.constants.php#constant.stream-filter-write">STREAM_FILTER_WRITE</a></code></strong> で
    <span class="function"><strong>stream_filter_prepend()</strong></span> を 2 回コールしなければなりません。
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-filter-prepend-seealso">
  <h3 class="title">参考</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.stream-filter-register.php" class="function" rel="rdfs-seeAlso">stream_filter_register()</a> - ユーザー定義のストリームフィルタを登録する</span></li>
   <li><span class="function"><a href="function.stream-filter-append.php" class="function" rel="rdfs-seeAlso">stream_filter_append()</a> - ストリームにフィルタを付加する</span></li>
  </ul>
 </div>

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