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

Dave Winter
Dave Winter
453 Points

Do you have to define what makes a boolean true/false every time you use them or do they always refer to number type?

In this example, the TRUE command is noted as any value that is a true value (1, -1, 1.0) and anything that is empty in any way is noted as FALSE. Is that the default association for TRUE and FALSE unless you define what they are?

For example, I'm curious if booleans would be used to detect a mobile device to revert code to a mobile-responsive format, or that would involve something else.

Murat Hasdemir
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Murat Hasdemir
Front End Web Development Techdegree Graduate 20,968 Points

for the first part of question True/False true can take 1,true in php. Never see -1 as a true but if you use it in Boolean== -1; that can be work because of converting of variables. Booleans can only take 4 different values (true,1,false,0) and while looking for if its equals in php system try to change second value to these ones like if using only positive numbers system automatically get rid from "-" or same as decimals system wont read number after decimal point and for false there are not much to do. For second part of the question thats not used like that but short cut answer there are identifiers like user-agents and screen resolution in css etc. to determine how to show website in browser.

1 Answer

Matthew Brock
Matthew Brock
16,791 Points

booleans are a basic data type. look at php's manual for more information

http://php.net/manual/en/language.types.boolean.php