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 Arrays and Control Structures PHP Conditionals Compare

Teacher Russell
Teacher Russell
16,873 Points

php arrays and control structure quiz question 1 of 5

I know the correct answer here, but just want to be sure I understand it. If you put a variable in a condition like this, instead of comparing it automatically reassigns the variable, so the condition must be true?

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Russell,

The questions in the quiz are randomly generated, so not always in the same order, but I think I know which one you are referring to. So, when referring to a specific question from a quiz, always copy / paste the actual question in the body of your post.

Now, to answer your question... No.
When you have variable = value, there is nothing to compare, as there is no comparison operator. Remember the single equal sign means "assign to" not "compare to". This will always return True, because it was successfully assigned. So, it's not that it "automatically reassigns the variable", it just simply assigns the variable that value because that is what you told it to do with the =.
To compare variable == value you must use the double equal sign symbol.

Hope that clears is up for you. :)
:dizzy:

Teacher Russell
Teacher Russell
16,873 Points

I was just coming back to delete my question because the answer popped into my head, while I was on to the next video. It was just time to take a break. I didn't really see the challenge clearly. It occurred to me later and I saw the challenge in my mind. Thanks so much for your help. A little embarrassed:)