Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Booleans are the simplest type of variable because a Boolean can only be one of two values: either true or false. There is no middle ground or gray area. There is no variation on truth, it either is or it isn't. We'll examine the way PHP views Boolean values and explore more of the basic features that PHP offers.
Documentation
Booleans are the simplest type. A boolean expresses a truth value. It can be either TRUE or FALSE.
Examples
var_dump((bool) ""); // bool(false)
var_dump((bool) 0); // bool(false)
var_dump((bool) 1); // bool(true)
var_dump((bool) -2); // bool(true)
var_dump((bool) "foo"); // bool(true)
var_dump((bool) 2.3e5); // bool(true)
var_dump((bool) array(12)); // bool(true)
var_dump((bool) array()); // bool(false)
var_dump((bool) "false"); // bool(true)
PHP Framework Interop Group (PHP-FIG) is a group of established PHP projects whose goal is to talk about commonalities between our projects and find ways we can work better together.
PHP Standards Recommendations (PSR-2) intent is to reduce cognitive friction when scanning code from different authors. It does so by enumerating a shared set of rules and expectations about how to format PHP code.
2.5. Keywords and True/False/Null
PHP keywords MUST be in lower case.
The PHP constants true, false, and null MUST be in lower case.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up