<HTML ><HEAD ><TITLE >Shared Memory Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" 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" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.session-write-close.html" ACCESSKEY="P" >Prev</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" >Next</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="AEN84823" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="shmop.intro" ></A >Introduction</H1 ><P > Shmop is an easy to use set of functions that allows PHP to read, write, create and delete UNIX shared memory segments. These functions will not typically work on Windows, as it does not support shared memory. As of Windows 2000 though, enabling the <TT CLASS="filename" >php_shmop.dll </TT >in your <TT CLASS="filename" >php.ini</TT > will enable this functionality though. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </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 >Requirements</H1 ><P >No external libraries are needed to build this extension.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="shmop.installation" ></A >Installation</H1 ><P > To use shmop you will need to compile PHP with the <TT CLASS="option" >--enable-shmop</TT > parameter in your configure line. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="shmop.configuration" ></A >Runtime Configuration</H1 ><P >This extension has no configuration directives defined in <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="shmop.resources" ></A >Resource Types</H1 ><P > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="shmop.constants" ></A >Predefined Constants</H1 ><P >This extension has no constants defined.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="shmop.examples" ></A >Examples</H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN84853" ></A ><P ><B >Example 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 ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</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" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.shmop-close.html" ACCESSKEY="N" >Next</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" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >shmop_close</TD ></TR ></TABLE ></DIV ></BODY ></HTML >