Shared memory is primarily used for interprocess communication
Shared Memory in PHP has two sets of extensions that can be implemented
1,Shmop need to open --enable-shmop parameters when compiling
Instance:
$shm _key= Ftok (__file__, ' t ');/** Open a piece of shared memory int $key, string $flags, int $mode, int $size $flags: A: Access read-only memory segment C: Create a new memory segment, or if the memory segment already exists, try to open it for read and write W: Writable memory segment N: Creates a new memory segment that fails if the memory segment already exists $mode: Octal format 0655$size: Data size bytes opened*/$shm _id= Shmop_open ($shm _key, "C", 0644, 1024);/** * Write data data must be in string format, the last point offset * Note: The offset must be within the specified range, otherwise not write **/$size= Shmop_write ($shm _id, ' Songjiankang ', 0);Echo"Write into {$size}";#The read range must also be within the requested memory range, otherwise the failure$data= Shmop_read ($shm _id, 0, 100);Var_dump($data);#Delete Just do a delete flag bit while not allowing the new process process to read and the system will automatically delete when no process is readShmop_delete ($shm _id);#Close the memory segmentShmop_close ($shm _id);
Reference: http://www.laruence.com/2008/04/21/101.html
http://www.yuansir-web.com/2012/09/22/php
PHP Shared Memory