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

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