![]() ![]() But, as discussed, isset($data) will also return false if $data was set, but was set to null. The author of this code presumably wanted to check if keyShouldBeSet was set in $data. do something here if 'keyShouldBeSet' is not set This behavior is more problematic than it might appear at first and is a common source of problems.Ĭonsider the following: $data = fetchRecordFromStorage($storage, $identifier) ![]() Unset($value) // $value no longer references $arrĬommon Mistake #2: Misunderstanding isset() behaviorÄespite its name, isset() not only returns false if an item does not exist, but also returns false for null values. To still get the benefit of using references in foreach loops without running the risk of these kinds of problems, call unset() on the variable, immediately after the foreach loop, to remove the reference e.g.: $arr = array(1, 2, 3, 4)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |