|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-11-05 14:29 UTC] moriyoshi@php.net
[2002-11-05 14:32 UTC] tim at afeindustries dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
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.