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 (Retired) PHP Conditionals & Loops Conditionals Challenge

Simon Tucker
Simon Tucker
9,113 Points

Hi, I'm a little stuck on the third objective on the if/else statement in php basics.

echo "Hi I am Mike!"

5 Answers

Simon, can you be more specific? Do you understand the syntax of the if statement? Something else? It should be:

if (some condition) {
    do something;
}

You know the condition ("test to see that the $name variable is set to the string 'Mike'") and you know the "something" to do (echo out "Hi, I am Mike!").

Simon Tucker
Simon Tucker
9,113 Points

Yeah understand but not sure what the question is asking.

is this close??

if($name == "Mike"){ $name = "Hi, I am Mike!" }

Yes, that's close. Do you remember how to use the "echo" command? That's what step 3 is asking you to do--echo out that string. In place of the "do something" in my example above, do that.

Simon Tucker
Simon Tucker
9,113 Points

<?php $name = "Mike"; if ($name == "Mike"){ echo "Hi, I am Mike!" } ?>

is this what they are asking?

Simon Tucker
Simon Tucker
9,113 Points

Hey thanks for that, I forgot a semi-colon..

You got it! Now remember this feeling next time...

Simon Tucker
Simon Tucker
9,113 Points

<?php $name = "Mike";

if ($name == "Mike")

{ echo "Hi, I am Mike!"; }

?>

correct code.