note 94232 deleted from language.operators.logical by hholzgra

From: Date: Thu, 02 Aug 2012 15:15:11 +0000
Subject: note 94232 deleted from language.operators.logical by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189839@lists.php.net to get a copy of this message
Note Submitter: Rob ---- Another example that might help. <?php (isset($panelemail) && !empty($panelemail) ? $panelemail : $userdata['email']); ?> returns the userdata email address, but this <?php (isset($panelemail) AND !empty($panelemail) ? $panelemail : $userdata['email']); ?> returns false. The reason is that the two types of ands have a different order of precedence. "&&" is higher than "AND", and the "?:" operator just happens to come between the two. Also, since "||" (or) is actually higher than "AND," you should never mix &&s and ||s with ANDs and ORs without paretheses. For example: <?php true && false || false ?> returns false, but <?php true AND false || false ?> returns true.

« previous php.notes (#189839) next »