note 108596 deleted from control-structures.alternative-syntax by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 16:40:47 +0000 |
| Subject: | note 108596 deleted from control-structures.alternative-syntax by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187575@lists.php.net to get a copy of this message | ||
Note Submitter: G. Stewart
----
In response to temec987 at gmail dot com, your tip doesn't work with echo because echo is not a
function. It doesn't return a value. print *is* a function that always returns (int)1.
In effect, you're taking advantage of a shortcut in the evaluation of a boolean expression.
When evaluating:
expression1 && expression2 (or expression1 AND expression2, it's the same thing)
if expression1 is FALSE then the result is necessarily FALSE since both expression1 and expression2
have to be TRUE for the whole to be TRUE.
Only if expression1 is TRUE (ie. if $value is set and not NULL) is there any point in evaluating
expression2 (the print()). echo not being a function, it cannot be evaluated a such.