On Thu, Nov 24, 2011 at 3:41 AM, David Muir <davidkm...@gmail.com> wrote:
> On 24/11/11 12:44, Ferenc Kovacs wrote: > > > > On Thu, Nov 24, 2011 at 1:38 AM, David Muir <davidkm...@gmail.com> wrote: > >> Just to clarify, the changes introduced in 5.4 will result in the >> following: >> >> <?php >> >> $string = 'foo'; >> $array = array( >> 'foo' => array( >> 'bar' => 'baz', >> //expected structure >> //'bar' => array('baz' => array('values')) >> )); >> >> var_dump( >> isset($string['foo']), //true >> isset($string[0][0]), //false, true in 5.4 >> isset($array['foo']['bar'][0]), //true >> isset($array['foo']['bar']['baz']), //true >> isset($array['foo']['bar']['baz']['0']) //false, true as of 5.4 >> isset($string['foo']['bar']['baz']['0']) //false, true as of 5.4 >> ); >> > > you are missing a comma from the end of the > isset($array['foo']['bar']['baz']['0']) //false, true as of 5.4 > line > > > Yeah, I added that one at the last minute. That's what I get for a quick > copy/paste... > > > > isset($string['foo']['bar']['baz']['0']) //false, true as of 5.4 > gives me a fatal error on 5.3 ("PHP Fatal error: Cannot use string offset > as an array" as you can't "chain" string offsets before 5.4) > > > It gives me false in 5.3.6. Using it outside of isset() results in the > fatal error. > hm. tyrael@thor:~$ php -r '$string = "foo";isset($string["foo"]["bar"]["baz"]["0"]);'; PHP Fatal error: Cannot use string offset as an array in Command line code on line 1 tyrael@thor:~$ php -v PHP 5.3.8-1~dotdeb.2 with Suhosin-Patch (cli) (built: Aug 25 2011 13:30:46) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH I will check this against a vanilla version, as there is a chance that either dotdeb(less likely) or suhosin patched something. -- Ferenc Kovács @Tyr43l - http://tyrael.hu