Sophie

Sophie

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

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
>shmop_open</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="Shared Memory Functions"
HREF="ref.shmop.html"><LINK
REL="PREVIOUS"
TITLE="shmop_delete"
HREF="function.shmop-delete.html"><LINK
REL="NEXT"
TITLE="shmop_read"
HREF="function.shmop-read.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
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.shmop-delete.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.shmop-read.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.shmop-open"
></A
>shmop_open</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN208996"
></A
><P
>    (PHP 4 &#62;= 4.0.4, PHP 5)</P
>shmop_open&nbsp;--&nbsp;Create or open shared memory block</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN208999"
></A
><H2
>说明</H2
>int <B
CLASS="methodname"
>shmop_open</B
> ( int key, string flags, int mode, int size )<BR
></BR
><P
>&#13;   <B
CLASS="function"
>shmop_open()</B
> can create or open a shared memory block.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN209018"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>key</CODE
></DT
><DD
><P
>&#13;       System'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
>&#13;       The flags that you can use:
       <P
></P
><UL
><LI
><P
>&#13;          "a" for access (sets SHM_RDONLY for shmat)
          use this flag when you need to open an existing shared memory
          segment for read only
         </P
></LI
><LI
><P
>&#13;          "c" 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
         </P
></LI
><LI
><P
>&#13;          "w" for read &#38; write access
          use this flag when you need to read and write to a shared memory
          segment, use this flag in most cases.
         </P
></LI
><LI
><P
>&#13;          "n" 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.
         </P
></LI
></UL
>
      </P
></DD
><DT
><CODE
CLASS="parameter"
>mode</CODE
></DT
><DD
><P
>&#13;       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 <TT
CLASS="literal"
>0644</TT
>
      </P
></DD
><DT
><CODE
CLASS="parameter"
>size</CODE
></DT
><DD
><P
>&#13;       The size of the shared memory block you wish to create in bytes
      </P
></DD
></DL
></DIV
>
   <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
     Note: the 3rd and 4th should be entered as 0 if you are opening an
     existing memory segment.
    </P
></BLOCKQUOTE
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN209054"
></A
><H2
>返回值</H2
><P
>&#13;   On success <B
CLASS="function"
>shmop_open()</B
> will return an id that you can
   use to access the shared memory segment you've created. <TT
CLASS="constant"
><B
>FALSE</B
></TT
> is 
   returned on failure.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN209059"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN209062"
></A
><P
><B
>例 1. Create a new shared memory block</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$shm_key </font><font color="#007700">= </font><font color="#0000BB">ftok</font><font color="#007700">(</font><font color="#0000BB">__FILE__</font><font color="#007700">, </font><font color="#DD0000">'t'</font><font color="#007700">);<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">$shm_key</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 /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   This example opened a shared memory block with a system id returned by
   <A
HREF="function.ftok.html"
><B
CLASS="function"
>ftok()</B
></A
>.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN209067"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.shmop-close.html"
><B
CLASS="function"
>shmop_close()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.shmop-delete.html"
><B
CLASS="function"
>shmop_delete()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </P
></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.shmop-delete.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-read.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>shmop_delete</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.shmop.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>shmop_read</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>