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

Under the variable $name create a if statement that test to see that the $name variable is set to the string 'Mike'?

Under the variable $name create a if statement that test to see that the $name variable is set to the string 'Mike'.

index.php
<?php
$name = "Mike";
if ($name = "Mike") {
  echo Mike;
?>
David Bath
David Bath
25,940 Points

What is your question? If you got an error, it's probably because you forgot your closing curly bracket.

1 Answer

Great job! :thumbsup: There are some errors, though. First, you made the $name variable, check. Second, when you want to get the value of $name, you need to use the exact same name, not the content of the variable. Lastly, you need the closing curly brace } for the if condition. Try this code:

<?php

$name = "Mike";

if ($name == "Mike") {
  echo $name;
}

?>

Hope that helps! :dizzy: