1. Home
  2. Computing & Technology
  3. PHP / MySQL

Boolean Logic

By Angela Bradley, About.com

Definition: Boolean logic is a type of decision making utilized by computers to decide if a statement is true or false. There are four main boolean operators used to evaluate a statement as true or false. They are:

&& - true if both operands are true
|| - true if at least one operand is true
xor - true if ONLY one operand is true
! - true if a single operand is false

Examples:
A is True
B is True
C is False

A && B
This is asking for A and B to both be true, since they are both true, this expression is TRUE

A || C
This is asking for A or C to be true. Again this is a TRUE expression

A xor B
This is asking for A or B but not both, to be true. Since they are both true, this expression is FALSE

!A
This is asking for A to be false. Since A is true, this expression is FALSE

!C
This is asking for C to be false. Since C is false, this expression is TRUE

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Programing Glossary
  5. Boolean Operator - Boolean Algebra - Boolean Logic

©2008 About.com, a part of The New York Times Company.

All rights reserved.