Re: [PHP-GTK] One more (was Re: [PHP-GTK] Assignment evalution weirdness)
[email protected] (Andrei Zmievski) Fri, 10 Aug 2001 12:07:28 -0500
| Newsgroups | php.gtk |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 10 Aug 2001, Markus Fischer wrote:
> In the same context, e.g. in a method from a class extending
> GtkWindow:
>
> // we assume $this->hash = array();
>
> var_dump( $this->hash[ 'foo']); // NULL
> $test = $this->hash;
> var_dump( $test[ 'foo']); // NULL, too, its ok
>
> if( isset( $test[ 'foo'])) { // works, doesn't enter the if
>
> // but
>
> if( isset( $this->hash[ 'foo'])) { // enters the if here
Here's my test:
class foo extends GtkWindow {
function foo() {
$this->hash['foo'] = array();
var_dump( $this->hash[ 'foo']); // NULL
$test = $this->hash;
var_dump( $test[ 'foo']); // NULL, too, its ok
if( isset( $test[ 'foo'])) { // works, doesn't enter the if
print 'isset( $test[ \'foo\']) worked'."\n";
}
// but
if( isset( $this->hash[ 'foo'])) { // enters the if here
print 'isset( $this->hash[ \'foo\']) worked'."\n";
}
}
}
$obj = new foo;
The result:
array(0) {
}
array(0) {
}
isset( $test[ 'foo']) worked
isset( $this->hash[ 'foo']) worked
So it works.
-Andrei
* Marriage is not a word. It's a sentence. Life-long sentence. *