<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.shmop.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.shmop-write.php',
    1 => 'shmop_write',
    2 => '共有メモリブロックにデータを書き込む',
  ),
  'up' => 
  array (
    0 => 'ref.shmop.php',
    1 => '共有メモリ関数',
  ),
  'prev' => 
  array (
    0 => 'function.shmop-size.php',
    1 => 'shmop_size',
  ),
  'next' => 
  array (
    0 => 'class.shmop.php',
    1 => 'Shmop',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/shmop/functions/shmop-write.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.shmop-write" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">shmop_write</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">shmop_write</span> &mdash; <span class="dc-title">共有メモリブロックにデータを書き込む</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.shmop-write-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>shmop_write</strong></span>(<span class="methodparam"><span class="type"><a href="class.shmop.php" class="type Shmop">Shmop</a></span> <code class="parameter">$shmop</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$offset</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="simpara">
   <span class="function"><strong>shmop_write()</strong></span> は、共有メモリブロックに文字列を書き込みます。
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.shmop-write-parameters">
  <h3 class="title">パラメータ</h3>
  <dl>
   
    <dt><code class="parameter">shmop</code></dt>
    <dd>
     <span class="simpara">
      <span class="function"><a href="function.shmop-open.php" class="function">shmop_open()</a></span> で作られた共有メモリブロックの識別子。
     </span>
    </dd>
   
   
    <dt><code class="parameter">data</code></dt>
    <dd>
     <span class="simpara">
      共有メモリブロックに書き込む文字列
     </span>
    </dd>
   
   
    <dt><code class="parameter">offset</code></dt>
    <dd>
     <span class="simpara">
      共有メモリセグメント内部のどこから、データを書き始めるかを指定します。
      この値は 0 以上、かつ共有メモリセグメントの実際のサイズ以下でなければいけません。
     </span>
    </dd>
   
  </dl>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.shmop-write-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="simpara">
   書き込んだ <code class="parameter">data</code> のサイズを返します。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.shmop-write-errors">
  <h3 class="title">エラー / 例外</h3>
  <p class="simpara">
   <code class="parameter">offset</code> が範囲外の値の場合、
   または読み取り専用の共有メモリセグメントに書き込んだ場合、
   <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> がスローされます。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.shmop-write-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       PHP 8.0.0 より前のバージョンでは、
       失敗した時に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返していました。
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       引数 <code class="parameter">shmop</code> は、
       <span class="classname"><a href="class.shmop.php" class="classname">Shmop</a></span> クラスのインスタンスを期待するようになりました。
       これより前のバージョンでは、リソースが期待されていました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.shmop-write-examples">
  <h3 class="title">例</h3>
  <div class="example" id="example-1">
   <p><strong>例1 共有メモリブロックに書き込む</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$shm_bytes_written </span><span style="color: #007700">= </span><span style="color: #0000BB">shmop_write</span><span style="color: #007700">(</span><span style="color: #0000BB">$shm_id</span><span style="color: #007700">, </span><span style="color: #0000BB">$my_string</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <p class="simpara">
   この例は、<code class="literal">$my_string</code> にあるデータを共有メモリブロックに書き込みます。
   <code class="literal">$shm_bytes_written</code> には、書かれたデータのバイト数が入ります。
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.shmop-write-seealso">
  <h3 class="title">参考</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.shmop-read.php" class="function" rel="rdfs-seeAlso">shmop_read()</a> - 共有メモリブロックからデータを読み取る</span></li>
  </ul>
 </div>

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