#20266 [NEW]: Logical OR fails if results of two methods are evaluated

From: Date: Tue, 05 Nov 2002 20:08:02 +0000
Subject: #20266 [NEW]: Logical OR fails if results of two methods are evaluated
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-24139@lists.php.net to get a copy of this message
From: tim@afeindustries.com Operating system: W2K PHP version: 4.2.2 PHP Bug Type: Class/Object related Bug description: Logical OR fails if results of two methods are evaluated Dear PHP TEAM, Thanks for such a great product. This baby makes our day, every day! We have recently found one strange thing. When we need to LOGICALLY-OR the results of two boolean methods of a class, PHP bypasses execution of the second method (if first method returns TRUE). Since the second method is never executed we can not get the desired result. Please, take a look at the body of the CONSTRUCTOR below: //---- BEGINNING OF FILE 'sample.php' class CSample { function CSample() { echo 'Some news are here:<br>'; // Below, PHP actually doesn't // runs $this->logicalTwo() if( $this->logicalOne() || $this->logicalTwo() ) { echo '<br>What more do you want?'; // .. } } // SERVICE METHODS function logicalOne() { //.. echo ' GOT CAR '; return true; } function logicalTwo() { //.. echo ' GOT MONEY '; return true; } }; // Instantiating the class $object1 = new CSample(); //---- END OF FILE 'sample.php' OUTPUT: Some news are here: GOT CAR What more do you want? See, there is no 'GOT MONEY' text printed. Please advise. Is this the correct behavior or something is not working right. Many thanks, Tim B. -- Edit bug report at http://bugs.php.net/?id=20266&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20266&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20266&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20266&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20266&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20266&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20266&r=support Expected behavior: http://bugs.php.net/fix.php?id=20266&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20266&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20266&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20266&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20266&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20266&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20266&r=isapi

« previous php.bugs (#24139) next »