note 106000 added to function.array-key-exists

From: Date: Sat, 01 Oct 2011 11:15:07 +0000
Subject: note 106000 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-183578@lists.php.net to get a copy of this message
As you might know, isset() is actually working like @$variable===NULL. As the result, it doesn't actually catch variables set to NULL. If you want to check if variable is set (even to NULL), you can use array_key_exists on $GLOBALS, like there. <?php $me = null; $se = 1; unset($se); // $he is not set if(array_key_exists('me', $GLOBALS)) echo "\$me exists\n"; if(array_key_exists('se', $GLOBALS)) echo "\$se exists\n"; if(array_key_exists('he', $GLOBALS)) echo "\$he exists\n"; ?> In this case, only $me will be detected as $se was removed when code was running and $he was never set. ---- Server IP: 82.177.164.100 Probable Submitter: 178.36.174.145 ---- Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php Edit -- https://master.php.net/note/edit/106000 Del: integrated -- https://master.php.net/note/delete/106000/integrated Del: useless -- https://master.php.net/note/delete/106000/useless Del: bad code -- https://master.php.net/note/delete/106000/bad+code Del: spam -- https://master.php.net/note/delete/106000/spam Del: non-english -- https://master.php.net/note/delete/106000/non-english Del: in docs -- https://master.php.net/note/delete/106000/in+docs Del: other reasons-- https://master.php.net/note/delete/106000 Reject -- https://master.php.net/note/reject/106000 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183578) next »