note 112011 added to function.isset

From: Date: Mon, 22 Apr 2013 05:39:18 +0000
Subject: note 112011 added to function.isset
Groups: php.notes 
Request: Send a blank email to php-notes+get-194590@lists.php.net to get a copy of this message
<?php return isset($nonexistentarray['foo']); ?> Returns false without trouble (assuming $nonexistent array does not exist). <?php $foo = 17; return isset($nonexistentarray[$foo]); ?> Also returns false without trouble. But, oddly, <?php return isset($nonexistentarray[$nonexistentkey]); ?> While returning false, also triggers a notice regarding the undefined variable "$nonexistentkey". Some thought shows that this is the right behaviour (we're testing for the existence of an array element, but we need to know which array element we're testing the existence of), but it probably isn't obvious. This implies that: <?php $extantarray[null] = 42; return isset($extantarray[$nonexistentkey]); ?> Triggers a notice and returns true. ---- Server IP: 103.6.212.224 Probable Submitter: 202.175.135.150 ---- Manual Page -- http://php.net/manual/en/function.isset.php Edit -- https://master.php.net/note/edit/112011 Del: integrated -- https://master.php.net/note/delete/112011/integrated Del: useless -- https://master.php.net/note/delete/112011/useless Del: bad code -- https://master.php.net/note/delete/112011/bad+code Del: spam -- https://master.php.net/note/delete/112011/spam Del: non-english -- https://master.php.net/note/delete/112011/non-english Del: in docs -- https://master.php.net/note/delete/112011/in+docs Del: other reasons-- https://master.php.net/note/delete/112011 Reject -- https://master.php.net/note/reject/112011 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194590) next »