View Full Version : Php if a AND b
Hey,
This has been annoying me for a bit now, I've tried googling, just isn't happening for me lol
I want to do something like this
if A and B are true
do this
else
do this
+rep to any help (:
Stephen
13-04-2011, 11:50 PM
if (a && b) {
do this
} else {
do this
}
you mean that? orrrr
Yeah, join the statements with && (logical AND) if you want both conditions satiisfied or || for either to be satisfied (logical OR).
$a = true;
$b = false;
if ($a && $b) {
echo "Both are true!";
} else {
echo "One of them or both are not true."; // This will be the result.
}
if ($a || $b) {
echo "At lease one is true"; // This will be the result.
} else {
echo "Neither is true.";
}
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.