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 trialSimon Tucker
9,113 PointsHi, I'm a little stuck on the third objective on the if/else statement in php basics.
echo "Hi I am Mike!"
5 Answers
James Gill
Courses Plus Student 34,936 PointsSimon, 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
9,113 PointsYeah understand but not sure what the question is asking.
is this close??
if($name == "Mike"){ $name = "Hi, I am Mike!" }
James Gill
Courses Plus Student 34,936 PointsYes, 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
9,113 Points<?php $name = "Mike"; if ($name == "Mike"){ echo "Hi, I am Mike!" } ?>
is this what they are asking?
Simon Tucker
9,113 PointsHey thanks for that, I forgot a semi-colon..
James Gill
Courses Plus Student 34,936 PointsYou got it! Now remember this feeling next time...
Simon Tucker
9,113 Points<?php $name = "Mike";
if ($name == "Mike")
{ echo "Hi, I am Mike!"; }
?>
correct code.