Re: Re: A little confusing thing on (mistakenly) geting a offset fromstring with multi dim index.
| From: | Aziz Saleh | Date: | Thu, 15 May 2014 02:12:43 +0000 |
| Subject: | Re: Re: A little confusing thing on (mistakenly) geting a offset fromstring with multi dim index. | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323323@lists.php.net to get a copy of this message | ||
On Wed, May 14, 2014 at 10:06 PM, Christoph Becker <cmbecker69@gmx.de>wrote:
> Rain Lee wrote:
>
> > I think the convert that cause the 'key' become 0 is ... not a good
> > idea. But my experience on PHP is so little, maybe there is some
> > reason for it that i never know.
>
> I have to agree that this behavior is somewhat unexpected. However, it
> seems to fit well to PHP's type juggling, which generally takes getting
> used to. And of course you can get around this behavior by making sure
> you have an array and not a string; consider making use of type hinting[1].
>
> > Don't know what's the opinion of those guys inside the PHP.
>
> Me neither. You might consider filing a feature request[2] or asking on
> php.internals[3].
>
> [1]
> <http://www.php.net/manual/en/language.oop5.typehinting.php>
> [2] <https://bugs.php.net/>
> [3] <news://news.php.net/php.internals>
>
> --
> Christoph M. Becker
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Trying different versions of php give different results:
http://sandbox.onlinephpfunctions.com/
$string = 'this is a string';
var_dump($string['check']);
var_dump(isset($string['check']));
var_dump(isset($string['check'][0]));
Biggest change from 5.3 -> 5.5
No idea why this is happening, like Chris said php internals might be a
good place to ask.