我在这里很新,我需要帮助。 你知道如何使用shmop_write php写超过1个字符串到共享内存吗?如何使用shmop_write php将多个字符串写入共享内存?
这是我的PHP语法:
$key = 864;
$mode = 'c';
$permission = 0644;
$size = 1024;
$shmid = shmop_open($key, $mode, $permission, $size);
$string = "This is String 1";
$string2 = "String 2";
shmop_write($shmid, $string, 0);
shmop_write($shmid, $string2, 0);
$size = shmop_size($shmid);
echo shmop_read($shmid, 0, $size);
shmop_delete($shmid);
shmop_close($shmid);
预期结果(通缉的结果):这是字符串1String 2
,但结果是语法的是:字符串2String 1
如果我改变$string = "String 1"
from $string = "This is String 1"
, 结果仍然如下:String 2String 1
(像不能刷新内存块)
你能告诉我如何得到想要的结果吗?谢谢。
'shmop_write($ shmid,$ string。$ string2,0);'? –
以不同的偏移量写入它们。 – Barmar