Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: shm_get_var - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net

search for in the

shm_put_var" width="11" height="7"/> <shm_detach
Last updated: Wed, 01 Nov 2006
view this page in

shm_get_var

(PHP 3 >= 3.0.6, PHP 4, PHP 5)

shm_get_var -- 共有メモリから変数を返す

説明

mixed shm_get_var ( int shm_identifier, int variable_key )

shm_get_var() は、 shm_identifier で指定した共有メモリセグメントから 変数 variable_key を読みこみます。 shm_identifier は、 shm_attach() から取得します。 読み込んだ変数は、まだ共有メモリに存在します。



add a note add a note User Contributed Notes
shm_get_var
JM
15-May-2005 07:50
To follow up on the posts by anonymous, Bob Van Zant and chris at free-source dot com below (or, as must people inexplicably write, above) regarding the PHP warning and FALSE that shm_get_var returns if the variable key doesn't exist:

My tests (with PHP4.3.4) show that defined() is useless here. Because the function defined(string) checks whether the constant whose name is string exists, the code
<?php
if ( defined(@shm_get_var($mutex, $mutex_key)) {
   ...
}
?>
acts the same ("..." does not get executed) whether the variable is defined or not--unless $mutex_key happens to identify a valid string that happens to be the name of a constant. :)

Rather,
<?php
if ( @shm_get_var($mutex, $mutex_key) === FALSE ) {
   ...
}
?>
works, provided the object that was stored isn't actually FALSE (via <?php shm_put_var($mutex, $mutex_key, FALSE); ?>)

It would be nice to have a completely air-tight solution, though.  D'oh!
06-May-2005 06:01
You will still receive a notice use @:

if(!defined(@shm_get_var($mutex, $mutex_key))) {
       shm_put_var($mutex, $mutex_key, 0);
}
Bob Van Zant
18-Feb-2005 05:05
This seems to work fine to detect the lack of presence of a key in shared memory and then init it to 0 when found:

if(!defined(shm_get_var($mutex, $mutex_key))) {
       shm_put_var($mutex, $mutex_key, 0);
}
chris at free-source dot com
06-Dec-2004 07:47
if the variable_key asked for does not exist php generates a warning and shm_get_var() will return bool(false).  there doesn't seem to be a clean way to test if a key exists.

shm_put_var" width="11" height="7"/> <shm_detach
Last updated: Wed, 01 Nov 2006
 
 
show source | credits | sitemap | contact | advertising | mirror sites