note 22132 deleted from function.shm-attach by didou

From: Date: Sun, 29 Aug 2004 21:41:20 +0000
Subject: note 22132 deleted from function.shm-attach by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75593@lists.php.net to get a copy of this message
Note Submitter: joeldegan at yahoo dot com ---- //shared memory example.. hope this helps // return a memory hex segment for string.. // limit four chars in Joel = 0x4a6f656c (joel is my name) function memsegspot($str){ $str = str_pad($str, 4, "Z"); // Z = 5a for ($a=0; $a<4; $a++){ $out1 = substr($str, $a , 1); // walk through $out .= dechex(ord($out1)); // ord returns dec, we need hex for shared memory segments }// return ("0x".$out); // prepend it with 0x }//end function $test = serialize("\nIf you can read this, it is coming out of shared memory..\n"); $ms = ((strlen($test)+44)*2); $sem_id = sem_get(memsegspot("test"), 1); echo $sem_id; sem_acquire($sem_id); $smh = shm_attach(memsegspot("test"), $ms); echo "Attached to shm # $smh\n"; shm_put_var ($smh, $shm_variable, $test); // $shm_variable is the variable stored, $test = the data echo "placed data in shm.\n"; echo shm_get_var($smh, $testing); @shm_detach($sem_id); echo "detached from shared memory..";

« previous php.notes (#75593) next »