Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics (Retired) PHP Conditionals & Loops Conditionals

Steven Meyer
Steven Meyer
933 Points

USE_FULL_NAME defined as boolean ??

USE_FULL_NAME is defined as boolean so we don't need:

if(USE_FULL_NAME == TRUE)

We can just as easily write:

if(USE_FULL_NAME)

I've tried it and it works

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Steven,

That is correct, in most languages boolean values can be evaluated without the need for an equality operator as the compiler will do that for us, however unless you know explicitly that value will always been either true or false it's common practice to use the triple equals === operator as that ensures that both the left and right values of the operator are equal to the same type and value rather than just comparing the value by itself, ie:

// This will only work if $some_variable evaluates as truthy value.
if ($some_variable === true)
Steven Meyer
Steven Meyer
933 Points

Thanks for that