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

Darya Zata
Darya Zata
2,562 Points

which of statements will throw false (php)

hello all,

i dont get this :

which of following statements will be tested as false when tested as boolean

$time=0; $num=-2; $boolean=true; $name='Treehouse';

thanku!

3 Answers

Hello Darya ,

The 0 in PHP is tested as False.

Cheers! , Juthawong Naisanguansee

$time=0;

Robert Bennett
Robert Bennett
11,927 Points

In Boolean values the logic is 0 is false and 1 is true or (false and true values). All Boolean values are on or off statements like a light switch. So, 0 is equal to false and 1 is equal to true. ex. $num 0 = 0; If(num === 0) {do this code.} The code will run because this is a true statement because 0 or false Boolean is equal to 0 the false Boolean value. I hope this helped.

Darya Zata
Darya Zata
2,562 Points

thanku for the answer, so to understand it right f(num === 0) {do this code.} The code will run because this is a true statement the statement itselt is true , but the value of the variable num is false (=0), correct?

Robert Bennett
Robert Bennett
11,927 Points

Yes, You got it... In The if("This has to be true to run") the $num 0 = 0; If($num 0 === 0 ) that is a true statement using a false Boolean... Two false Boolean that are equality to each other is a true statement...