necessary, in which case the optional size and permissions arguments will be used
if present.
The size of the memory segment defaults to a value defined when PHP is compiled.
Minimum and maximum values for the size are dependent on the operating system, but
reasonable values to expect are a 1-byte minimum and a 128K maximum. There are also
limits on the number of shared memory segments. Normal limits are 100 total segments
and 6 segments per process.
The permissions for a memory segment default to 0x666, which is read and write
permission to all users. This value operates like those used to set file permissions.
As with semaphores, calling shm_attach for the same key twice will return two
different identifiers, yet they will both point to the same shared memory segment
internally.
Keep in mind that shared memory does not expire automatically. You must free it using
shm_remove.
<?
/*
Shared Memory example
This example builds on the semaphore example
by using shared memory to communicate between
multiple processes. This example creates shared
memory but does not release it. Make sure you
run the shm_remove example when you're done
experimenting with this example.
*/
//Define integer for semaphore key
define("SEM_COREPHP", 1970);
//Define integer for shared memory key
define("SHM_COREPHP", 1970);
//Define integer for variable key
define("SHMVAR_MESSAGE", 1970);
//Get or create the semaphore
//This semaphore can only be acquired once
$sem = sem_get(SEM_COREPHP, 1);
//acquire semaphore
if(sem_acquire($sem))