Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics (Retired) PHP Conditionals & Loops Conditionals Challenge

PHP Conditionals and Loops

Hi guys, please help, l am stuck on this: Finally, echo the following string inside of the if statement: 'Hi, I am Mike!' Thank you! <?php $name="Mike"; if($name=="Mike"){ $info="Hi, l am Mike!"; } ?> this is being said to be wrong so anyone with an idea please help, thank you!

index.php
<?php
$name="Mike";
if($name=="Mike"){
  $info="Hi, l am Mike!";
}
?>

Thank you, but it is still saying thats not the correct answer

I believe this comes down to a typography error after you fix it to echo the statement. In your code you have a lowercase L instead of an uppercase i.

Thank you very much guys, l appreciate your contributions so much, l have passed and it was also typographical error, Corey you were right

You're very welcome. If you could please mark one answer as correct that way hopefully the next person who has a similar issue can easily find a solution.

2 Answers

Instead of setting the variable info to include your string of text simply return it to the browser

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

Optionally if you would like to use the same string later you can leave the variable set and include the echo command on a new line to return your string to the browser.

<?php
$name="Mike";
if($name=="Mike"){
  $info =  "Hi, I am Mike!";
  echo $info;
}
?>
Gary Stewart
Gary Stewart
14,142 Points

Within the if statement you are only setting the string as a variable, you need to then echo that for it to be displayed.

You can either echo the variable:

echo $info;

Or best option is to echo it directly so replace $info = with echo.

echo "Hi, I am Mike!";

Thank you very much guys, l appreciate your contributions so much, l have passed and it was also typographical error