Re: variable_exists() patch
| From: | Andrey Hristov | Date: | Sat, 16 Aug 2003 16:30:27 +0000 |
| Subject: | Re: variable_exists() patch | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4022@lists.php.net to get a copy of this message | ||
oooh,
here is easy sollution for global vars :
<?php
var_dump(array_key_exists('a',$GLOBALS));
$a = NULL;
var_dump(array_key_exists('a',$GLOBALS));
?>
However there is no $LOCALS in the local scope.
Andrey
----- Original Message -----
From: "Cristiano Duarte" <cunha17@uol.com.br>
To: <internals@lists.php.net>
Sent: Saturday, August 16, 2003 7:26 PM
Subject: Re: [PHP-DEV] variable_exists() patch
> "Stefan Walk" <swalk@prp.physik.tu-darmstadt.de> escreveu na mensagem
> news:20030816075011.GA3576@prp0.prp.physik.tu-darmstadt.de...
> > class Foo {
> > function dump() {
> > var_dump(array_key_exists('bar', (array)$this));
> > }
> > }
> > $foo = new Foo;
> > $foo->bar = null;
> > $foo->dump();
> > // => bool(true)
> >
> > It's not that hard to detect.
> IMHO, array_key_exists can be used this way, but it shouldn't. The
function
> name has a meaning specific for arrays. We must have a not so specific way
> to detect if a variable(or attribute) exists or not.
>
> Cristiano Duarte.
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>