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 Daily Exercise Program Review Basics

Hey There
Hey There
3,086 Points

Why is $time = 0; would be considered FALSE when tested as a boolean?

I'm not sure why. Can someone explain it?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hey There! In programming languages we have the concept of "truthy" and "falsey". Some values are considered to be "true" and other values "false". This is not specific to PHP. Other languages such as Python, JavaScript, Swift and more also have this concept. In many of them, any non-zero value is considered to be "true" while any value that is zero is considered to be "false".

If you check this PHP documentation under the "Converting to Booleans" section you can see all values that are considered "falsey" in PHP.

Hope this helps! :sparkles:

Hey There
Hey There
3,086 Points

Thank you Jennifer!