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 trialScott Murray
8,353 PointsDoesn't make sense...
Since you set $a = 0 which is the same as $a = false, wouldn't !$a be the same as saying $a is NOT false thus equally true???
1 Answer
Scott Murray
8,353 PointsI understand and thank you for responding. I honestly feel like the beginning PHP course is purposely full of trick questions to trip you up and I'm finding it to be quite annoying. Here's the link to the video: https://teamtreehouse.com/library/negation-operator
Scott Murray
8,353 PointsLike, on this quiz:
What will be displayed in a browser when the following PHP code is executed:
<?php $a = "Alena"; if ($a = "Treehouse") { echo "Hello Alena, "; } echo "Welcome to Treehouse!"; ?>
TIP: Check the OPERATORS
I find this to be a trick question.
andren
28,558 Pointsandren
28,558 PointsYou don't link to the video or code you are discussing so I don't know the context of your question. But the ! operator simply reverses booleans. So
true
is treated asfalse
and vice versa.So if
$a
contains 0 (which is essentiallyfalse
as you stated) then the ! would invert it so that it is considered to betrue
.If you link to the video or code in question then I might be able to give a better explanation of what is confusing you.