Re: PHP 7.1 - Address PHPSadness #28?

From: Date: Fri, 18 Sep 2015 13:44:49 +0000
Subject: Re: PHP 7.1 - Address PHPSadness #28?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-88321@lists.php.net to get a copy of this message
On Wed, Aug 26, 2015 at 5:09 AM, Scott Arciszewski <scott@paragonie.com> wrote: > Hi everybody, > > Would anyone be interested in adding another helper like > isset()/empty() simply called exists() which would return true if the > variable is defined in the current scope (i.e. without raising an > E_NOTICE)? > > It should be a simple change to add this function but it's too late > for 7.0 so, if there is any interest, I would respectfully put it off > until 7.1. After reading through this thread (most of it anyway), the thing that strikes me is that many people expect the wrong thing from isset(). I believe that the reason for this is that the name isset() is slightly misleading. I wouldn't blame anyone for assuming that it acually checks that a variable "is set", and not even considering the corner case of when it does exist with a null value. What lesson can we learn from that? Short and sweet names sometimes lead to problems, if they do not precisely convey the actual semantics. I would much rather see a function called something like is_variable_defined(), to avoid running into the same trap with exists(). No room for assumptions that lead you to not check the docs. - Stig

« previous php.internals (#88321) next »