<HTML ><HEAD ><TITLE >Shared Memory Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html"><LINK REL="UP" TITLE="Referencia de las Funciones" 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=ISO-8859-1"></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 de 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" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.shmop" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XCIV. Shared Memory Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN70417" ></A ><P > Shmop is an easy to use set of functions that allows php to read, write, create and delete UNIX shared memory segments. The functions will not work on windows, as it does not support shared memory. To use shmop you will need to compile php with the --enable-shmop parameter in your configure line. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > The functions explained in the chapter begin all with <B CLASS="function" >shm_()</B > in PHP 4.0.3, but in PHP 4.0.4 and later versions these names are changed to begin with <B CLASS="function" >shmop_()</B >. </P ></BLOCKQUOTE ></DIV ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN70424" ></A ><P ><B >Ejemplo 1. Shared Memory Operations Overview</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php // Create 100 byte shared memory block with system id if 0xff3 $shm_id = shmop_open(0xff3, "c", 0644, 100); if(!$shm_id) { echo "Couldn't create shared memory segment\n"; } // Get shared memory block's size $shm_size = shmop_size($shm_id); echo "SHM Block Size: ".$shm_size. " has been created.\n"; // Lets write a test string into shared memory $shm_bytes_written = shmop_write($shm_id, "my shared memory block", 0); if($shm_bytes_written != strlen("my shared memory block")) { echo "Couldn't write the entire length of data\n"; } // Now lets read the string back $my_string = shmop_read($shm_id, 0, $shm_size); if(!$my_string) { echo "Couldn't read from shared memory block\n"; } echo "The data inside shared memory was: ".$my_string."\n"; //Now lets delete the block and close the shared memory segment if(!shmop_delete($shm_id)) { echo "Couldn't mark shared memory block for deletion. } shmop_close($shm_id); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Tabla de contenidos</B ></DT ><DT ><A HREF="function.shmop_close.html" >shmop_close</A > -- Close shared memory block</DT ><DT ><A HREF="function.shmop_delete.html" >shmop_delete</A > -- Delete shared memory block</DT ><DT ><A HREF="function.shmop_open.html" >shmop_open</A > -- Create or open shared memory block</DT ><DT ><A HREF="function.shmop_read.html" >shmop_read</A > -- Read data from shared memory block</DT ><DT ><A HREF="function.shmop-size.html" >shmop_size</A > -- Get size of shared memory block</DT ><DT ><A HREF="function.shmop_write.html" >shmop_write</A > -- 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" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.shmop_close.html" ACCESSKEY="N" >Siguiente</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" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >shmop_close</TD ></TR ></TABLE ></DIV ></BODY ></HTML >