|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-13 11:00 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 00:00:02 2025 UTC |
Description: ------------ In my function (see code below) i tried to return the value of an array at position "key" If the value is null, i want to return null - it works as shown in the code - but if the key is not set - my function also returns "null"! So i can't find a solution to differ "null" or "not set"! Reproduce code: --------------- $a = array(); // case 1: $a["key"] = null; // end case 1 // case 2: // end case 2 if (isset($a["key"])) { return $a["key"]; } else { if (is_null($a["key"]) return null; else return "key not set!"; } Expected result: ---------------- case 1: null case 2: "key not set!" Actual result: -------------- case 1: null case 2: null >> Undefined Index: key in XXX (in log file)