note 56778 deleted from function.echo by nlopess
| From: | nlopess@php.net | Date: | Mon, 16 Jul 2007 18:01:34 +0000 |
| Subject: | note 56778 deleted from function.echo by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128623@lists.php.net to get a copy of this message | ||
Note Submitter: lorenpr at gmail dot com
----
linus is correct.
The ternary relationship is evaluated first, then echo prints the result.
Also, keep in mind
(condition? a : b)
reads
if(condition) return a; else return b;
So what makes
A. echo ($somevar) ? 'true' : 'false';
different from
B. ($somevar) ? echo 'true' : echo 'false';
is the ternary relationship in A reads
if (condition) return 'true'; else return 'false';
while in B it reads
if(condition) return (echo 'true'); else return (echo 'false');
- an invalid statement, since echo evaluates to void.