Menu
Coddy logo textTech

Booleans

Part of the Fundamentals section of Coddy's PHP journey — lesson 8 of 71.

Boolean variables can only hold one of two possible values: true or false.

Note that these values are case-sensitive, meaning they must be lowercased.

Here is an example of assigning a bool value to a variable:

$variable_true = true;
$variable_false = false;

In the above, two variables named variable_true and variable_false are initialized, with the values true and false respectively.

Booleans are the building blocks for creating logic in the programs we write. We have a whole chapter about logic and conditions.

Cheat sheet

Boolean variables hold one of two values: true or false (case-sensitive, must be lowercased).

$variable_true = true;
$variable_false = false;

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals