note 52852 added to function.shm-get-var

From: Date: Sat, 14 May 2005 22:50:17 +0000
Subject: note 52852 added to function.shm-get-var
Groups: php.notes 
Request: Send a blank email to php-notes+get-89439@lists.php.net to get a copy of this message
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! ---- Manual Page -- http://www.php.net/manual/en/function.shm-get-var.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52852 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52852&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52852&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52852&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52852&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52852&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52852&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89439) next »