Re: Function-return-array idea

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm sure I'm a pea-brain, but this caught my attention.

So you execute the fetchObjects() method which could return a large
number of objects, then you reference a method of the 0th one.

I didn't test, but why not use: $object->fetchObjects(0)->method();

Where fetchObjects($id) returns the object referenced by $id instead of all?

-Shawn

echo $object->fetchObjects()[0]->method();

Stijn Leenknegt 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.
> 
> http://www.eos-team.org/2007/09/06/php6-function-return-array-idea.html
> 
> I hope for good response and also response from php-dev team.
> 
> Greetings
> Stijn Leenknegt
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux