PHP IPC函数介绍---共享内存
2012-11-23 09:31
225 查看
以下是php的共享内存常用函数,用于进程间的通信
shm_attach — Creates or open a shared memory segment
shm_detach — Disconnects from shared memory segment
shm_get_var — Returns a variable from shared memory
shm_has_var — Check whether a specific entry exists
shm_put_var — Inserts or updates a variable in shared memory
shm_remove_var — Removes a variable from shared memory
shm_remove — Removes shared memory from Unix systems
输出:hello world
shm_attach — Creates or open a shared memory segment
shm_detach — Disconnects from shared memory segment
shm_get_var — Returns a variable from shared memory
shm_has_var — Check whether a specific entry exists
shm_put_var — Inserts or updates a variable in shared memory
shm_remove_var — Removes a variable from shared memory
shm_remove — Removes shared memory from Unix systems
$msg_key=1; $ipc_key=ftok(__FILE__,'t'); $seg=shm_attach($ipc_key,1024,0600); //创建或打开一个共享内存段 if(!$seg){ die('create or open shared memory segment failed!'); } shm_put_var($seg,$msg_key,'hello world'); if(shm_has_var($seg,$msg_key)){ $content=shm_get_var($seg,$msg_key); echo $content; } shm_remove_var($seg,$msg_key); shm_remove($seg);
输出:hello world
相关文章推荐
- PHP管理内存函数 memory_get_usage()使用介绍
- PHP IPC函数介绍---消息队列
- IPC简单介绍(二)共享内存
- 共享内存及信号量的几个函数介绍
- shmop 系列函数使用 php共享内存
- linux ftok()函数 --多进程IPC之共享内存
- IPC——共享内存与信号灯的基本函数整理
- PHP管理内存函数 memory_get_usage()使用介绍
- PHP IPC函数介绍---信号量
- 进程间通信IPC之--共享内存
- PHP会话处理相关函数介绍
- PHP json_encode() 函数介绍
- 进程间通信(IPC)(1)—— 管道、共享内存
- PHP json_encode() 函数介绍
- PHP实现数字补零功能的2个函数介绍
- 【2016/1】 Unix IPC 信号 共享内存 消息队列
- linux基础编程:进程通信之System V IPC:消息队列,信号量,共享内存
- PHP eval函数使用介绍
- 细说linux IPC(三):mmap系统调用共享内存
- 使用mmap函数进行内核空间和用户空间的共享内存通信