RE: [PHP] True || False ?

From: Date: Fri, 16 Feb 2001 05:43:53 +0000
Subject: RE: [PHP] True || False ?
Groups: php.general 
Request: Send a blank email to php-general+get-40108@lists.php.net to get a copy of this message
oops ... I think I got too far from your original question: yes, function returnMeFoo($foo=0) { if($foo) return true; return false; } if(returnMeFoo()) echo 'you will not see this echo'; elseif(returnMeFoo(1)) echo 'but if you see this means the function returned as true'; Cheers, Maxim Maletsky -----Original Message----- From: Maxim Maletsky Sent: Friday, February 16, 2001 2:40 PM To: 'Jonathan Sharp'; php-general@lists.php.net; 'Jeff Oien' Subject: RE: [PHP] True || False ? Yeah, sure you can, if return is found in function it then exits it. for example avoiding 'else' statements: function returnMeFoo($foo=0) { if(!$foo) return "Hey, you forgot to type a number in"; if($foo>5) return "$foo is bigger then 5"; if($foo<5) return "$foo is less then 5"; return "Then, logically, $foo *IS* 5"; } // then call this function as echo '<P>'.returnMeFoo(4); echo '<P>'.returnMeFoo(5); echo '<P>'.returnMeFoo(6); And see how fun it is! Cheers, Maxim Maletsky -----Original Message----- From: Jonathan Sharp [mailto:jonathan@flyerware.com] Sent: Friday, February 16, 2001 1:26 PM To: php-general@lists.php.net Subject: [PHP] True || False ? How does php handle true and false? Do they act as true booleans? Can I do? function foo() { return false; } Thanks, -Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#40108) next »