note 56778 added to function.echo
| From: | lorenpr at gmail dot com | Date: | Thu, 15 Sep 2005 03:58:55 +0000 |
| Subject: | note 56778 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95194@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.echo.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56778
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56778&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56778&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56778&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56778&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56778&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56778&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56778&report=yes
Search -- http://master.php.net/manage/user-notes.php