PHP use function return value as array

后端 未结 3 837
悲哀的现实
悲哀的现实 2021-01-22 03:32

Why is it that this works:

        $cacheMatchesNotPlayed = $cache->load(\'externalData\');
        $cacheMatchesNotPlayed = $cacheMatchesNotPlayed[\'matchesN         


        
相关标签:
3条回答
  • 2021-01-22 03:56

    PHP just does not support array dereferencing in the way you have described. Also covered here:

    PHP syntax for dereferencing function result

    0 讨论(0)
  • 2021-01-22 03:56

    PHP does not support the function array dereferencing, which you want to do.

    See an RFC on the subject http://wiki.php.net/rfc/functionarraydereferencing, and the associated mailing list conversations, which was declined roughly this time last year. While there was support for this, and it's still a common request (usually "why doesn't this work?"), there are no plans in motion to introduce this syntax.

    As for why, quite simply the code implementing it has not been submitted for approval (if it has been written at all).

    Update

    This feature has been implemented in the trunk (main development) branch of PHP and will likely be included in the next non-bugfix version (5.4.0). For anyone wanting to play with FAD, feel free to download a trunk snapshot.

    0 讨论(0)
  • 2021-01-22 04:04

    Because PHP does not support that syntax.

    0 讨论(0)
提交回复
热议问题