|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-11-08 10:06 UTC] l_faillie at yahoo dot com
Description:
------------
Hi all,
It seems only one variable can be stored in a SHM zone.
Reproduce code:
---------------
Source 1 : storing variables
$shm = shm_attach( 2710, 512);
shm_put_var( $shm, 'val', 'blabla');
shm_put_var( $shm, 'jour', date('D'));
Source 2 : reading variables
$shm = shm_attach( 2710, 512);
echo 'val :', shm_get_var($shm, 'val'), "\n";
echo 'jour :', shm_get_var($shm, 'jour'), "\n";
Expected result:
----------------
val :blabla
jour :Sat
Actual result:
--------------
val :Sat
jour :Sat
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
In fact, you should use an array if you want to store multiple information. Source 1 : storing variables $shm = shm_attach( 2710, 512); $data = array('val'=>'blabla', 'jour'=> date('D')); shm_put_var( $shm, 'data', serialize($data)); Source 2 : reading variables $shm = shm_attach( 2710, 512); $data = unserialize(shm_get_var($shm, 'data')); echo 'val :', $data['val'], "\n"; echo 'jour :', $data['jour'], "\n";