<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.streamwrapper.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'streamwrapper.stream-lock.php',
    1 => 'streamWrapper::stream_lock',
    2 => 'Advisory file locking',
  ),
  'up' => 
  array (
    0 => 'class.streamwrapper.php',
    1 => 'streamWrapper',
  ),
  'prev' => 
  array (
    0 => 'streamwrapper.stream-flush.php',
    1 => 'streamWrapper::stream_flush',
  ),
  'next' => 
  array (
    0 => 'streamwrapper.stream-metadata.php',
    1 => 'streamWrapper::stream_metadata',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/stream/streamwrapper/stream-lock.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="streamwrapper.stream-lock" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">streamWrapper::stream_lock</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">streamWrapper::stream_lock</span> &mdash; <span class="dc-title">Advisory file locking</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-streamwrapper.stream-lock-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>streamWrapper::stream_lock</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$operation</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   This method is called in response to <span class="function"><a href="function.flock.php" class="function">flock()</a></span>, when
   <span class="function"><a href="function.file-put-contents.php" class="function">file_put_contents()</a></span> (when <code class="parameter">flags</code>
   contains <strong><code><a href="filesystem.constants.php#constant.lock-ex">LOCK_EX</a></code></strong>),
   <span class="function"><a href="function.stream-set-blocking.php" class="function">stream_set_blocking()</a></span> and when closing the stream
   (<strong><code><a href="filesystem.constants.php#constant.lock-un">LOCK_UN</a></code></strong>).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-streamwrapper.stream-lock-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">operation</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">operation</code> is one of the following:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="filesystem.constants.php#constant.lock-sh">LOCK_SH</a></code></strong> to acquire a shared lock (reader).
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="filesystem.constants.php#constant.lock-ex">LOCK_EX</a></code></strong> to acquire an exclusive lock (writer).
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="filesystem.constants.php#constant.lock-un">LOCK_UN</a></code></strong> to release a lock (shared or exclusive).
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="filesystem.constants.php#constant.lock-nb">LOCK_NB</a></code></strong> if you don&#039;t want
          <span class="function"><a href="function.flock.php" class="function">flock()</a></span> to block while locking.
          (not supported on Windows)
         </span>
        </li>
       </ul>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-streamwrapper.stream-lock-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> on success or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-streamwrapper.stream-lock-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Emits <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> if call to this method fails (i.e. not implemented).
  </p>
 </div>

 



 <div class="refsect1 seealso" id="refsect1-streamwrapper.stream-lock-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.stream-set-blocking.php" class="function" rel="rdfs-seeAlso">stream_set_blocking()</a> - Set blocking/non-blocking mode on a stream</span></li>
    <li><span class="function"><a href="function.flock.php" class="function" rel="rdfs-seeAlso">flock()</a> - Portable advisory file locking</span></li>
   </ul>
  </p>
 </div>


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