<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.shmop-write" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>shmop_write</refname>
  <refpurpose>Write data into shared memory block</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>int</type><methodname>shmop_write</methodname>
   <methodparam><type>Shmop</type><parameter>shmop</parameter></methodparam>
   <methodparam><type>string</type><parameter>data</parameter></methodparam>
   <methodparam><type>int</type><parameter>offset</parameter></methodparam>
  </methodsynopsis>
  <para>
   <function>shmop_write</function> will write a string into shared memory block.
  </para>
 </refsect1>
 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>shmop</parameter></term>
     <listitem>
      <para>
       The shared memory block identifier created by 
       <function>shmop_open</function>
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>data</parameter></term>
     <listitem>
      <para>
       A string to write into shared memory block 
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>offset</parameter></term>
     <listitem>
      <para>
       Specifies where to start writing data inside the shared memory
       segment. The offset must be greater than or equal to zero
       and less than or equal to the actual size of the shared memory segment.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   The size of the written <parameter>data</parameter>.
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   If <parameter>offset</parameter> is out of range, or a read-only shared memory segment
   should be written to, a <classname>ValueError</classname> is thrown.
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <informaltable>
   <tgroup cols="2">
    <thead>
     <row>
      <entry>&Version;</entry>
      <entry>&Description;</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry>8.0.0</entry>
      <entry>
       Prior to PHP 8.0.0, &false; was returned on failure.
      </entry>
     </row>
     <row>
      <entry>8.0.0</entry>
      <entry>
       <parameter>shmop</parameter> expects a <classname>Shmop</classname>
       instance now; previously, a <type>resource</type> was expected.
      </entry>
     </row>
    </tbody>
   </tgroup>
  </informaltable>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Writing to shared memory block</title>
    <programlisting role="php">
<![CDATA[
<?php
$shm_bytes_written = shmop_write($shm_id, $my_string, 0);
?>
]]>
    </programlisting>
   </example>
  </para>
  <para>
   This example will write data inside <literal>$my_string</literal> into
   shared memory block, <literal>$shm_bytes_written</literal> will contain
   the number of bytes written.
  </para>
 </refsect1>
 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>shmop_read</function></member>
   </simplelist>
  </para>
 </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
