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

Rustam Turaev
Rustam Turaev
4,644 Points

Hello Alena question

<?php $a = "Alena"; if ($a = "Treehouse") { echo "Hello Alena, "; } echo "Welcome to Treehouse!"; ?>

How does it display: "Hello Alena, Welcome to Treehouse", when $a is not equal "Treehouse", I don't understand...

1 Answer

Muhammad Ehsan Hanif
Muhammad Ehsan Hanif
8,236 Points

Hi

You need to use ($a == "Treehouse").

"=" is an assignment operator which assigns value on the left to the variable on the right.

"==" checks if values/variables on left and right are equal.

There is a video here which discuss these in detail, you may want to have a look at that.

Thanks