Re: Function-return-array idea
| From: | Nathan Nobbe | Date: | Thu, 17 Jan 2008 22:38:17 +0000 |
| Subject: | Re: Function-return-array idea | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267516@lists.php.net to get a copy of this message | ||
On Jan 16, 2008 6:32 PM, Stijn Leenknegt <stijnleenknegt@gmail.com> wrote:
> Hello
>
> I've an idea for PHP6. Let's kickoff with an example.
>
> <?php
> $info = getUserInformation($id); //return an array with all the
> information
> of an user.
> echo $info['naam'];
> ?>
>
> This is nice, but when I want one element of the returned array, I have to
> store the returned array into a variable and then call the variable.
> The next code example is my idea.
>
> <?php
> echo getUserInformation($id)['naam'];
> ?>
>
> Let's look further then this small example.
>
> <?php
> echo $object->fetchObjects()[0]->method();
> ?>
>
> This example is more realistic when you use OO. This code style is faster
> for developing applications. This code style is available in Java,
> Javascript, C, C++, Perl, Python, ... So why not in PHP(6)? You can read
> more on my blog
i think this is pretty much a dup of a thread from about a week ago;
http://www.nabble.com/Why-is-some_function()-some_index--invalid-syntax--td14749459.html
-nathan