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 Datatypes Strings

Niclas Valentiner
Niclas Valentiner
8,947 Points

Booleans and comparison

I find it curious that all the boolean comparison examples are done with typecasting.

I mean a strict comparison between 0 and FALSE shows up as FALSE (aka not the same). For the people who don't know what a strict comparison is: A normal comparison is == and ignores types. Eg. 0 == "0" returns TRUE. A strict comparison is === and compares types too. Eg. 0 === "0" returns FALSE because it compares an integer and a string.

To me this video seems a little likely to lead people astray to where they might end up thinking that 0 === FALSE would return TRUE.

Hampton is apparently not a part of TTH anymore but I still felt like I should point this out.

1 Answer

Hi Niclas Valentiner,

0 and FALSE aren't identical. 0 is a number and FALSE is a boolean value. 0 returns false. PHP castes 0 to false.

Niclas Valentiner
Niclas Valentiner
8,947 Points

Ehhh, this wasn't meant as a question really but more as an addendum to the video itself.

If you read it again you'll see that I said 0 and FALSE aren't identical, that a strict comparison returns FALSE (not the same).

I don't so, Hampton was very clear.