Re: 'odd' handling of $moo['bar'] where $moo is a string
| From: | Sean Coates | Date: | Thu, 09 Feb 2006 22:08:52 +0000 |
| Subject: | Re: 'odd' handling of $moo['bar'] where $moo is a string | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-21828@lists.php.net to get a copy of this message | ||
> Now, it seems that $keys['file'] == $keys[0], which makes sense why the issets
> return true. However...
> if ('file') echo 'true';
> will print moo, therefore 'file' == 1, not 0. Why is this different when using
> it as a string offset?
> IMO, using a string as a string offset, a fatal error should be raised.
It's cast to an integer.
sean@iconoclast:~$ php -r 'echo (int) "file" . "\n";'
0
sean@iconoclast:~$ php -r 'echo (bool) "file" . "\n";'
1
S