note 108596 added to control-structures.alternative-syntax
| From: | G.Stewart | Date: | Wed, 09 May 2012 11:36:55 +0000 |
| Subject: | note 108596 added to control-structures.alternative-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187544@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.197
Probable Submitter: 88.98.38.185
----
Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php
Edit -- https://master.php.net/note/edit/108596
Del: integrated -- https://master.php.net/note/delete/108596/integrated
Del: useless -- https://master.php.net/note/delete/108596/useless
Del: bad code -- https://master.php.net/note/delete/108596/bad+code
Del: spam -- https://master.php.net/note/delete/108596/spam
Del: non-english -- https://master.php.net/note/delete/108596/non-english
Del: in docs -- https://master.php.net/note/delete/108596/in+docs
Del: other reasons-- https://master.php.net/note/delete/108596
Reject -- https://master.php.net/note/reject/108596
Search -- https://master.php.net/manage/user-notes.php