Posted in PHP onJanuary 20, 2014
需要安装扩展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
编译安装成功
# 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 $shmid = shmop_open(864, 'c', 0755, 1024); shmop_write($shmid, "Hello World!", 0); phpinfo(); ?>
读数据
<?php $shmid = shmop_open(864, 'c', 0755, 1024); shmop_write($shmid, "Hello World!", 0); echo shmop_read($shmid, 0, 11); ?>
php共享内存段示例分享
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@