RE: [PHP-WIN] using result of function in same line
| From: | Stoner, David M. | Date: | Thu, 06 Nov 2003 17:44:54 +0000 |
| Subject: | RE: [PHP-WIN] using result of function in same line | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-22020@lists.php.net to get a copy of this message | ||
I've never seen a language where you couldn't do things like "echo foo() ;"
and I've seen a good many languages. It's so universal, I don't know that
it has a name, other than "expression evaluation". Language processors
typically evaluate inner subexpressions first, then use the value in
evaluating the containing expression.
That said, I'm still pretty new to PHP, so as far as I know PHP may be
deficient in that capability.
-----Original Message-----
From: Igor Belagorudsky [mailto:iggy1@hotmail.com]
Sent: Wednesday, November 05, 2003 7:27 PM
To: php-windows@lists.php.net
Subject: [PHP-WIN] using result of function in same line
ok here's the problem - in some languages (like javascript or c# for
instance) you could use the results of a function in same line as your call.
say you have a function foo that returns an array, you can do something like
print foo()[4];
this will print the 5th element of whatever array foo returned. but in php,
it seems like you have to break it up into 2 calls like this:
$x = foo();
echo $x[4];
i find it hard to believe that you can't do
echo foo()[4];
so... how can u go about this?
thanks,
igor
and also, what is that called when you can do it in same line?
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php