shmop_open: Create or open shared memory block(创建或打开共享内存块)
shmop_read: Read data from shared memory block(从共享内存块读取数据)
shmop_size: Get size of shared memory block(获取共享内存块的大小)
shmop_write: Write data into shared memory block(向共享内存块写数据)
相关使用例子:
<?php
//Create 1000 byte shared memory block with system id if 0xff1
$shm_id = shmop_open(0xff1, "c", 0644, 1000);
if(!$shm_id){
echo "fail to create shared memory segment\n";
}
//Get size of shared memory block
$shm_size = shmop_size($shm_id);
echo "The shared memory block size is :".$shm_size."\n";
//Write data into shared memroy
$shm_bytes = shmop_write($shm_id, "key message data", 0);
if($shm_bytes != strlen("key message data")){
echo "fail to write the entire length of data\n";
}
//Read data from the shared memory
$my_data = shmop_read($shm_id, 0, $shm_size);
if(!$my_data){
echo "fail to read data from shared memory block\n";
}
echo "The data inside shared memory is :".$my_data."\n";
//Delete the shared memory block and close the shared memory segment
if(!$shmop_delete($shm_id)){
echo "fail to mark shared memory block for deletion \n";
}
shmop_close($shm_id);
?>
共享内存shmop系列函数:shmop_close : Close shared memory block(关闭共享内存块)shmop_delete: Delete shared memory block(删除共享内存块)shmop_open: Create or open shared memory block(创建或打开共享内存块)shmop_read: Read data from...