Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 6220

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>Create or open shared memory block</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.shmop-delete.html">shmop_delete</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.shmop-read.html">shmop_read</a></div>
 <div class="up"><a href="ref.shmop.html">Shared Memory Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.shmop-open" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">shmop_open</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">shmop_open</span> &mdash; <span class="dc-title">Create or open shared memory block</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.shmop-open-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>shmop_open</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$flags</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code></span>
   )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>shmop_open()</strong></span> can create or open a shared memory block.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.shmop-open-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

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

     <dd>

      <p class="para">
       System&#039;s id for the shared memory block.
       Can be passed as a decimal or hex.
      </p>
     </dd>

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

     <dd>

      <p class="para">
       The flags that you can use:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          &quot;a&quot; for access (sets SHM_RDONLY for shmat)
          use this flag when you need to open an existing shared memory
          segment for read only
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;c&quot; for create (sets IPC_CREATE)
          use this flag when you need to create a new shared memory segment
          or if a segment with the same key exists, try to open it for read
          and write
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;w&quot; for read &amp; write access
          use this flag when you need to read and write to a shared memory
          segment, use this flag in most cases.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;n&quot; create a new memory segment (sets IPC_CREATE|IPC_EXCL)
          use this flag when you want to create a new shared memory segment
          but if one already exists with the same flag, fail. This is useful
          for security purposes, using this you can prevent race condition
          exploits.
         </span>
        </li>
       </ul>
      </p>
     </dd>

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

     <dd>

      <p class="para">
       The permissions that you wish to assign to your memory segment, those
       are the same as permission for a file. Permissions need to be passed
       in octal form, like for example <em>0644</em>
      </p>
     </dd>

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

     <dd>

      <p class="para">
       The size of the shared memory block you wish to create in bytes
      </p>
     </dd>

    
   </dl>

   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
     Note: the 3rd and 4th should be entered as 0 if you are opening an
     existing memory segment.
    </p>
   </p></blockquote>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.shmop-open-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   On success <span class="function"><strong>shmop_open()</strong></span> will return an resource that you can
   use to access the shared memory segment you&#039;ve created. <strong><code>FALSE</code></strong> is 
   returned on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.shmop-open-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.0.0</td>
      <td>
       The return type of <span class="function"><strong>shmop_open()</strong></span> has been changed from
       <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> to <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.shmop-open-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4586">
    <p><strong>Example #1 Create a new shared memory block</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$shm_key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ftok</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'t'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$shm_id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">shmop_open</span><span style="color: #007700">(</span><span style="color: #0000BB">$shm_key</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"c"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0644</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   This example opened a shared memory block with a system id returned by
   <span class="function"><a href="function.ftok.html" class="function">ftok()</a></span>.
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.shmop-open-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.shmop-close.html" class="function" rel="rdfs-seeAlso">shmop_close()</a> - Close shared memory block</span></li>
    <li class="member"><span class="function"><a href="function.shmop-delete.html" class="function" rel="rdfs-seeAlso">shmop_delete()</a> - Delete shared memory block</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.shmop-delete.html">shmop_delete</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.shmop-read.html">shmop_read</a></div>
 <div class="up"><a href="ref.shmop.html">Shared Memory Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>