Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 12265

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Shared Memory Functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="函数参考"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="session_write_close"
HREF="function.session-write-close.html"><LINK
REL="NEXT"
TITLE="shmop_close"
HREF="function.shmop-close.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="reference"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.session-write-close.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.shmop-close.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.shmop"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>CL. Shared Memory Functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN208884"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.intro"
>简介</A
></H1
><P
>&#13;     Shmop is an easy to use set of functions that allows PHP to read,
     write, create and delete Unix shared memory segments.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      Versions of Windows previous to Windows 2000 do not support shared memory.
      Under Windows, Shmop will only work when PHP is running as a web server
      module, such as Apache or IIS (CLI and CGI will not work).
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      In PHP 4.0.3, these functions were prefixed by <TT
CLASS="literal"
>shm</TT
>
      rather than <TT
CLASS="literal"
>shmop</TT
>.
     </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.requirements"
>需求</A
></H1
><P
>要编译本扩展模块无需外部库文件。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.installation"
>安装</A
></H1
><P
>&#13;  To use shmop you will need to compile PHP with the
  <CODE
CLASS="option"
>--enable-shmop</CODE
> parameter in your
  configure line.
 </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.configuration"
>运行时配置</A
></H1
><P
>本扩展模块在 <TT
CLASS="filename"
>php.ini</TT
> 中未定义任何配置选项。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.resources"
>资源类型</A
></H1
><P
>&#13;    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.constants"
>预定义常量</A
></H1
><P
>本扩展模块未定义任何常量。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.examples"
>范例</A
></H1
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN208914"
></A
><P
><B
>例 1. Shared Memory Operations Overview</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;<br /></font><font color="#FF8000">// Create 100 byte shared memory block with system id of 0xff3<br /></font><font color="#0000BB">$shm_id </font><font color="#007700">= </font><font color="#0000BB">shmop_open</font><font color="#007700">(</font><font color="#0000BB">0xff3</font><font color="#007700">, </font><font color="#DD0000">"c"</font><font color="#007700">, </font><font color="#0000BB">0644</font><font color="#007700">, </font><font color="#0000BB">100</font><font color="#007700">);<br />if (!</font><font color="#0000BB">$shm_id</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Couldn't create shared memory segment\n"</font><font color="#007700">;<br />}<br /><br /></font><font color="#FF8000">// Get shared memory block's size<br /></font><font color="#0000BB">$shm_size </font><font color="#007700">= </font><font color="#0000BB">shmop_size</font><font color="#007700">(</font><font color="#0000BB">$shm_id</font><font color="#007700">);<br />echo </font><font color="#DD0000">"SHM Block Size: " </font><font color="#007700">. </font><font color="#0000BB">$shm_size </font><font color="#007700">. </font><font color="#DD0000">" has been created.\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Lets write a test string into shared memory<br /></font><font color="#0000BB">$shm_bytes_written </font><font color="#007700">= </font><font color="#0000BB">shmop_write</font><font color="#007700">(</font><font color="#0000BB">$shm_id</font><font color="#007700">, </font><font color="#DD0000">"my shared memory block"</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">);<br />if (</font><font color="#0000BB">$shm_bytes_written </font><font color="#007700">!= </font><font color="#0000BB">strlen</font><font color="#007700">(</font><font color="#DD0000">"my shared memory block"</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Couldn't write the entire length of data\n"</font><font color="#007700">;<br />}<br /><br /></font><font color="#FF8000">// Now lets read the string back<br /></font><font color="#0000BB">$my_string </font><font color="#007700">= </font><font color="#0000BB">shmop_read</font><font color="#007700">(</font><font color="#0000BB">$shm_id</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">$shm_size</font><font color="#007700">);<br />if (!</font><font color="#0000BB">$my_string</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Couldn't read from shared memory block\n"</font><font color="#007700">;<br />}<br />echo </font><font color="#DD0000">"The data inside shared memory was: " </font><font color="#007700">. </font><font color="#0000BB">$my_string </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">//Now lets delete the block and close the shared memory segment<br /></font><font color="#007700">if (!</font><font color="#0000BB">shmop_delete</font><font color="#007700">(</font><font color="#0000BB">$shm_id</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Couldn't mark shared memory block for deletion."</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">shmop_close</font><font color="#007700">(</font><font color="#0000BB">$shm_id</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.shmop-close.html"
>shmop_close</A
>&nbsp;--&nbsp;Close shared memory block</DT
><DT
><A
HREF="function.shmop-delete.html"
>shmop_delete</A
>&nbsp;--&nbsp;Delete shared memory block</DT
><DT
><A
HREF="function.shmop-open.html"
>shmop_open</A
>&nbsp;--&nbsp;Create or open shared memory block</DT
><DT
><A
HREF="function.shmop-read.html"
>shmop_read</A
>&nbsp;--&nbsp;Read data from shared memory block</DT
><DT
><A
HREF="function.shmop-size.html"
>shmop_size</A
>&nbsp;--&nbsp;Get size of shared memory block</DT
><DT
><A
HREF="function.shmop-write.html"
>shmop_write</A
>&nbsp;--&nbsp;Write data into shared memory block</DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.session-write-close.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.shmop-close.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>session_write_close</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>shmop_close</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>