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 thekey
value (first parameter) supposed to be? I copied the0xF00
from an example, and I found that42
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.
精彩评论