note 105935 added to iterator.valid

From: Date: Mon, 26 Sep 2011 23:12:13 +0000
Subject: note 105935 added to iterator.valid
Groups: php.notes 
Request: Send a blank email to php-notes+get-183459@lists.php.net to get a copy of this message
Take consideration when utilizing this method and using the returned value of isset([value]). The value of isset([value]) will be false for null values. I ran into this problem when checking isset([value]) against array elements whose value was null. Example: <?php $array = array(null, 1, 2, 3); $isSet = isset($array[0]); var_dump($isSet); // output: boolean(false) class AClass { public $array = (null, 1, 2, 3); function valid() { return isset($this->array[0]); } } $class = new AClass; var_dump($class->valid()); // output: boolean(false) ?> ---- Server IP: 69.147.83.197 Probable Submitter: 69.73.113.128 ---- Manual Page -- http://www.php.net/manual/en/iterator.valid.php Edit -- https://master.php.net/note/edit/105935 Del: integrated -- https://master.php.net/note/delete/105935/integrated Del: useless -- https://master.php.net/note/delete/105935/useless Del: bad code -- https://master.php.net/note/delete/105935/bad+code Del: spam -- https://master.php.net/note/delete/105935/spam Del: non-english -- https://master.php.net/note/delete/105935/non-english Del: in docs -- https://master.php.net/note/delete/105935/in+docs Del: other reasons-- https://master.php.net/note/delete/105935 Reject -- https://master.php.net/note/reject/105935 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183459) next »