note 32337 deleted from language.operators.logical by colder
| From: | colder@php.net | Date: | Fri, 20 Apr 2007 15:38:59 +0000 |
| Subject: | note 32337 deleted from language.operators.logical by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125697@lists.php.net to get a copy of this message | ||
Note Submitter: hop
----
Dear Newbie,
(as i don't see such ideas creeping up in experienced programmers' minds...)
please don't pay attantion to shadedecho's post from 14-Mar-2003 04:02! He is heavily
relying on obscure side effects, which is not only very bad programming practice, but also does not
achieve the optimization he thinks it is.
The proper way to make this
if ( ($a .= blah()) || ($a .= blah2()) ) {
echo $a;
}
work like shadedecho wants is (although the example as a whole is rather inapt):
$a .= blah();
$a .= blah2();
if ($a) { echo $a; }
If you read the discussion he links to you will find that he really wanted to get all distinct
entries from two different db tables. Even there he is mistaken. The proper way to do this is to
process the first table and then process the second table.
This is not only far more readable than the workaround with '|', it is also not the least
slower.
Thanks.