开发者

Using shmop in PHP

开发者 https://www.devze.com 2022-12-07 19:05 出处:网络
I’m experimenting with shmop, but the online documentation and other examples are a bit thin on explanation.

I’m experimenting with shmop, but the online documentation and other examples are a bit thin on explanation.

Here is a simple script to test the concept:

$shmop = shmop_open(0xF00,'c',0644,128) ;
shmop_write($shmop,'goodbye',0);
shmop_write($shmop,'hello',0);
$data = trim(shmop_read($shmop,0,0));
print "[$data]";
print strlen($data);

There are a few things I don’t understand:

  • 开发者_运维知识库with shmop_open what is the key value (first parameter) supposed to be? I copied the 0xF00 from an example, and I found that 42 doesn’t work. How do I determine a suitable value?
  • when I run the script, the shorter string doesn’t replace the longer string. I get that it’s just writing into memory, but how should I clear out the older value?

Any help would be appreciated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号