Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 12087

php-manual-pt_BR-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
>Funções de Memória Compartilhada</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Referência das Funções"
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"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.session-write-close.html"
ACCESSKEY="P"
>Anterior</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"
>Próxima</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. Funções de Memória Compartilhada</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN204247"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.intro"
>Introdução</A
></H1
><P
>&#13;     Shmop é um fácil caminho para usar funções que permitem o PHP ler,
     escrever, criar e deletar segmentos de memória compartilhada UNIX. Note que versões
     do Windows anteriores ao Windows 2000 não suportam memória compartilhada.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      No PHP 4.0.3, estas funções estão prefixadas por <TT
CLASS="literal"
>shm</TT
>
      ao invés de <TT
CLASS="literal"
>shmop</TT
>.
     </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.requirements"
>Dependências</A
></H1
><P
>Nenhuma biblioteca externa é necessária para compilar esta extensão.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.installation"
>Instalação</A
></H1
><P
>&#13;  Para usar shmop você precisará compilar o PHP com o parâmetro
  <CODE
CLASS="option"
>--enable-shmop</CODE
> na seu configure.
 </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.configuration"
>Configurações em execução</A
></H1
><P
>Esta extensão não define nenhum parâmetro de configuração no <TT
CLASS="filename"
>php.ini</TT
>.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.resources"
>Tipos Resource</A
></H1
><P
>&#13;    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.constants"
>Constantes pré-definidas</A
></H1
><P
>Esta extensão não possui nenhuma constante.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="shmop.examples"
>Exemplos</A
></H1
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN204275"
></A
><P
><B
>Exemplo 1. Visão Geral de Operações de Memória Compartilhada</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 if 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
>Índice</B
></DT
><DT
><A
HREF="function.shmop-close.html"
>shmop_close</A
>&nbsp;--&nbsp;Fecha um bloco de memória compartilhada</DT
><DT
><A
HREF="function.shmop-delete.html"
>shmop_delete</A
>&nbsp;--&nbsp;Deleta um bloco de memória compartilhada</DT
><DT
><A
HREF="function.shmop-open.html"
>shmop_open</A
>&nbsp;--&nbsp;Cria ou abre um bloco de memória compartilhada</DT
><DT
><A
HREF="function.shmop-read.html"
>shmop_read</A
>&nbsp;--&nbsp;Lê dados de um bloco de memória compartilhada</DT
><DT
><A
HREF="function.shmop-size.html"
>shmop_size</A
>&nbsp;--&nbsp;Pega o tamanho do bloco de memória compartilhada </DT
><DT
><A
HREF="function.shmop-write.html"
>shmop_write</A
>&nbsp;--&nbsp;Escreve dados em um bloco de memória compartilhada</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"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.shmop-close.html"
ACCESSKEY="N"
>Próxima</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"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>shmop_close</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>