This class implements a user-space stream that reads/writes shared memory. It requires the shmop extension for shared memory access.
require_once('Stream/SHM.php'); stream_register_wrapper('shm','Stream_SHM') or die("can't register shm"); $shm = fopen('shm://0xabcd:12000','c'); fwrite($shm, 'One Two Three Four'); fseek($shm,4,SEEK_SET); $two = fread($shm,3); // $two is "Two" fclose($shm);
Specify the key of the shared memory segment in decimal or hexadecimal after the "shm://" and then optionally, a colon and the size of the shared memory segment. If you don't specify a size, the segment size defaults to 16384 bytes.
Allowable modes are "a", "c", "w", and "n". For what those modes mean, see: --> http://www.php.net/manual/en/function.shmop-open.php