PHP/Utility Function/shmop Functions
Sharing Variables Between Processes
<?php
if (!extension_loaded("shmop")) {
dl("php_shmop.dll");
}
$shm_id = shmop_open(0x123, "c", 0644, 250);
shmop_write($shm_id, "Data in shared memory", 0);
$value = shmop_read($shm_id, 8, 6);
echo "$value";
shmop_close($shm_id);
sleep(60);
?>
shmop Functions
Name Description
shmop_open() Opens or creates a memory block for sharing
shmop_close() Closes a shared memory block
shmop_delete() Deletes a shared memory block
shmop_read() Reads data from a shared memory block
shmop_write() Writes data to a shared memory block
shmop_size() Gets the size of a shared memory block
<?php
if (!extension_loaded("shmop")) {
dl("php_shmop.dll");
}
$shm_id = shmop_open(0x123, "a", 0, 0);
if ($shm_id) {
$value = shmop_read($shm_id, 0, 100);
echo "$value";
shmop_close($shm_id);
}
?>