Home > Backend Development > PHP Tutorial > php共享内存段示例分享_php实例

php共享内存段示例分享_php实例

WBOY
Release: 2016-06-07 17:22:29
Original
871 people have browsed it

 
需要安装扩展shmop
找到php安装源文件目录

复制代码 代码如下:

# cd /usr/local/php-5.4.0/ext/shmop
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
#  make && make install

编译安装成功

php共享内存段示例分享_php实例

复制代码 代码如下:

# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
多出一个 shmop.so
在php.ini增加shmop.so
extension=shmop.so
; Module Settings ;
phpinfo()输出


php共享内存段示例分享_php实例
 

写数据

复制代码 代码如下:

$shmid = shmop_open(864, 'c', 0755, 1024);
shmop_write($shmid, "Hello World!", 0);
phpinfo();
?>

读数据

复制代码 代码如下:

$shmid = shmop_open(864, 'c', 0755, 1024);
shmop_write($shmid, "Hello World!", 0);
echo shmop_read($shmid, 0, 11);
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template