note 68800 added to control-structures.elseif
| From: | phpprogrammer at artspad dot net | Date: | Fri, 11 Aug 2006 05:58:56 +0000 |
| Subject: | note 68800 added to control-structures.elseif | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115783@lists.php.net to get a copy of this message | ||
The comment critizing matheo's code while making some perhaps interesting statements about code
efficiency missed the point completely.
echo 0; is different then echo false;
echo 0 will print a 0
echo false will print nothing.
So, the ternary operator technique was simply assuring there would be a displayable value.
If anything matheo showed prowess as a programmer and that he was knowledgable about nuances in php
programming by knowing how to use the ternary operator to provide values true and false that are
displayable.
Perhaps a clearer example of this would have been:
$is_a_bigger = ($a > $b) ? "true" : "false" ;
It is true that the result of a logic expression is a value like any other, it is a value though of
a specific type which if using === can be checked for boolean logic which may or may not be what a
programmer wants.
The general caveat if we are going to pontificate to programmers is to know exacly what you are
getting from any operation and know the consequences of doing so. Which I think matheo knew quite
well, and appropriately accounted for.
----
Server IP: 64.71.164.2
Probable Submitter: 71.117.64.209
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/control-structures.elseif.php
Edit -- https://master.php.net/note/edit/68800
Del: integrated -- https://master.php.net/note/delete/68800/integrated
Del: useless -- https://master.php.net/note/delete/68800/useless
Del: bad code -- https://master.php.net/note/delete/68800/bad+code
Del: spam -- https://master.php.net/note/delete/68800/spam
Del: non-english -- https://master.php.net/note/delete/68800/non-english
Del: in docs -- https://master.php.net/note/delete/68800/in+docs
Del: other reasons-- https://master.php.net/note/delete/68800
Reject -- https://master.php.net/note/reject/68800
Search -- https://master.php.net/manage/user-notes.php