Re: variable_exists() patch
| From: | Stefan Walk | Date: | Thu, 14 Aug 2003 21:01:17 +0000 |
| Subject: | Re: variable_exists() patch | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-3965@lists.php.net to get a copy of this message | ||
On Thu, Aug 14, 2003 at 12:00:26PM -0700, walt boring wrote:
> It can happen quite easily. I always develop with full warnings/errors on.
So do I.
> So if for example a var isn't set for whatever reason, then trying to
> access the
> variable will throw a php Notice. variable_exists() would prevent that,
> as does isset().
Correct, isset works.
> isset() would work for my example below, but it still is a 'broken'
> function in my opinion.
>
> if ($var) { // <-- you'll get a php notice on this line
> switch ($var) {
> ...
> }
>
> }
>
> versus doing
>
> if (variable_exists($var)) { //no php notices here
> switch($var) {
> ...
> }
> }
As you already stated, isset works also. I asked for an occasion where
your variable_exists would be useful because isset does not work.
DB arguments don't count, if a value is null in a database it is
considered - you guessed it - not set.
I simply don't see a need for this.
--
Regards,
Stefan Walk
<swalk@prp.physik.tu-darmstadt.de>