php-doc-en/reference/sync/syncsharedmemory/read.xml
2018-01-25 15:56:34 +00:00

128 lines
3.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="syncsharedmemory.read" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SyncSharedMemory::read</refname>
<refpurpose>Copy data from named shared memory</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <methodname>SyncSharedMemory::read</methodname>
<methodparam choice="opt"><type>int</type><parameter>start</parameter><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
</methodsynopsis>
<para>
Copies data from named shared memory.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>start</parameter></term>
<listitem>
<para>
The start/offset, in bytes, to begin reading.
</para>
<note>
<para>
If the value is negative, the starting position will begin at the specified
number of bytes from the end of the shared memory segment.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>length</parameter></term>
<listitem>
<para>
The number of bytes to read.
</para>
<note>
<para>
If unspecified, reading will stop at the end of the shared memory segment.
</para>
<para>
If the value is negative, reading will stop the specified number of bytes
from the end of the shared memory segment.
</para>
</note>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A string containing the data read from shared memory.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>SyncSharedMemory::__construct</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// You will probably need to protect shared memory with other synchronization objects.
// Shared memory goes away when the last reference to it disappears.
$mem = new SyncSharedMemory("AppReportName", 1024);
if ($mem->first())
{
// Do first time initialization work here.
}
$result = $mem->write("report.txt");
$result = $mem->read(3, -4);
var_dump($result);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
string(3) "ort"
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><methodname>SyncSharedMemory::__construct</methodname></member>
<member><methodname>SyncSharedMemory::first</methodname></member>
<member><methodname>SyncSharedMemory::write</methodname></member>
<member><methodname>SyncSharedMemory::read</methodname></member>
</simplelist>
</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
-->