PHP Boolean

Boolean is a data type that can be represented by either true or false.

A boolean can be used with conditional statements to determine whether a statement should be executed.

PHP Booelan Example

  Do It Yourself

Boolean Conversion

using (bool) or (boolean) you can explicitly convert other data types to boolean.

PHP Booelan Conversion Example

  Do It Yourself

Logical NOT(!)

The logical NOT(!) used with logical values takes a truthy value turns it to false and vice versa.

PHP Boolean Logical NOT Example

  Do It Yourself

What You Should Know at The End of this Lesson

  • You should know about the boolean data type.
  • You should know how to convert other data types to boolean.
  • You should know how to use the logical NOT to invert logical values.