On 23/09/15 10:57, Rowan Collins wrote: >> array_key_exists(“var”, get_defined_vars()) && is_null($var) > > I wondered if someone would mention that, but didn't want to drift too > far from the point, which was the "prior to call is_null()" part of > Lester's sentence was redundant, since the problem was entirely > unrelated to is_null().
That the more modern way of working would be to perhaps remain in the 'associative array' space is a fact. Using expand() and then rebuilding the expanded array along with all the other variables seems an even more torturous fix to a simple problem. Yes from one point of view the problem is not with is_null() and I can agree with that. The problem is that one can't establish that a call to is_null() is going to access a valid variable while only working in the simple procedural layer. While 'exists()' may seem to be unnecessary, it returns an answer which makes subsequent work flow a LOT more consistent. exists() -> empty() or is_null() answers all cases and isset() is redundant but for BC reasons can't be removed. Using isset() in place of exists() is NOT a valid substitution since one can't then call is_null() KNOWING that the variable does exist. If the variables are being created - or not - in this program flow, then a check for exists() will establish if the variable needs creating, while isset() will miss and overwrite a variable if it was quite legitimately already created as null. If the default state is 'null' then there is not a problem, but if that null is trying to override another default ... we have hopefully established that the null state is a natural result of interaction with a database, but PHP has lost some of that special handling by simply treating it as 'just another value' as now happens by namespaces being able to override it. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php