note 32337 added to language.operators.logical

From: Date: Fri, 23 May 2003 21:53:41 +0000
Subject: note 32337 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-48924@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/language.operators.logical.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32337 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32337&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32337&report=yes

« previous php.notes (#48924) next »