Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 6600

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Attach a filter to a stream</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-filter-append.html">stream_filter_append</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-filter-register.html">stream_filter_register</a></div>
 <div class="up"><a href="ref.stream.html">Stream Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><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)</p><p class="refpurpose"><span class="refname">stream_filter_prepend</span> &mdash; <span class="dc-title">Attach a filter to a stream</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-filter-prepend-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>stream_filter_prepend</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stream</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$filtername</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$read_write</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$params</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Adds <code class="parameter">filtername</code> to the list of filters
   attached to <code class="parameter">stream</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-filter-prepend-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">stream</code></dt>

     <dd>

      <p class="para">
       The target stream.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">filtername</code></dt>

     <dd>

      <p class="para">
       The filter name.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">read_write</code></dt>

     <dd>

      <p class="para">
       By default, <span class="function"><strong>stream_filter_prepend()</strong></span> will
       attach the filter to the <em>read filter chain</em>
       if the file was opened for reading (i.e. File Mode:
       <em>r</em>, and/or <em>+</em>).  The filter
       will also be attached to the <em>write filter chain</em>
       if the file was opened for writing (i.e. File Mode:
       <em>w</em>, <em>a</em>, and/or <em>+</em>).
       <strong><code>STREAM_FILTER_READ</code></strong>,
       <strong><code>STREAM_FILTER_WRITE</code></strong>, and/or
       <strong><code>STREAM_FILTER_ALL</code></strong> can also be passed to the
       <code class="parameter">read_write</code> parameter to override this behavior.
       See <span class="function"><a href="function.stream-filter-append.html" class="function">stream_filter_append()</a></span> for an example of
       using this parameter.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">params</code></dt>

     <dd>

      <p class="para">
       This filter will be added with the specified <code class="parameter">params</code>
       to the <em class="emphasis">beginning</em> of the list and will therefore be
       called first during stream operations.  To add a filter to the end of the
       list, use <span class="function"><a href="function.stream-filter-append.html" 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">Return Values</h3>
  <p class="para">
   Returns a resource on success or <strong><code>FALSE</code></strong> on failure. The resource can be
   used to refer to this filter instance during a call to
   <span class="function"><a href="function.stream-filter-remove.html" class="function">stream_filter_remove()</a></span>.
  </p>

  <p class="para">
   <strong><code>FALSE</code></strong> is returned if <code class="parameter">stream</code> is not a resource or
   if <code class="parameter">filtername</code> cannot be located.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.stream-filter-prepend-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.1.0</td>
       <td>
        Prior to PHP 5.1.0, this function returns <strong><code>TRUE</code></strong> on success
        or <strong><code>FALSE</code></strong> on failure.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-filter-prepend-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <strong>When using custom (user) filters</strong><br />
   <span class="simpara">
    <span class="function"><a href="function.stream-filter-register.html" class="function">stream_filter_register()</a></span> must be called first
    in order to register the desired user filter to <code class="parameter">filtername</code>.
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Stream data is read from resources (both local and remote) in chunks,
    with any unconsumed data kept in internal buffers.  When a new
    filter is prepended to a stream, data in the internal buffers,
    which has already been processed through other filters will
    <em class="emphasis">not</em> be reprocessed through the new filter
    at that time.  This differs from the behavior of
    <span class="function"><a href="function.stream-filter-append.html" class="function">stream_filter_append()</a></span>.
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    When a filter is added for read and write, two instances of the filter
    are created. <span class="function"><strong>stream_filter_prepend()</strong></span> must be called twice 
    with <strong><code>STREAM_FILTER_READ</code></strong> and 
    <strong><code>STREAM_FILTER_WRITE</code></strong> to get both filter resources.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-filter-prepend-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.stream-filter-register.html" class="function" rel="rdfs-seeAlso">stream_filter_register()</a> - Register a user defined stream filter</span></li>
   <li class="member"><span class="function"><a href="function.stream-filter-append.html" class="function" rel="rdfs-seeAlso">stream_filter_append()</a> - Attach a filter to a stream</span></li>
  </ul>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-filter-append.html">stream_filter_append</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-filter-register.html">stream_filter_register</a></div>
 <div class="up"><a href="ref.stream.html">Stream Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>