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

STAGE 5 CHALLENGE TASK 2 0F 3

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") {
 $info ="Hi Mike";   
   }
?>

2 Answers

andorfermichael
andorfermichael
9,859 Points
<?php
     $name = "Mike"
     if ($name === "Mike") {
         $info = "Hi Mike";   
   }
?>

I think this should be the solution. You need three equal signs. The task wants you to prove if the $name variable is set to the string 'Mike'. You need to prove if it is identical. Therefore you have to prove if it is a string and if it is Mike. Two equal signs prove the content of the variable, three equal signs prove not only the content but also the type of the variable.

I hope this will help you.

Shawn Flanigan
PLUS
Shawn Flanigan
Courses Plus Student 15,815 Points

You're actually doing a bit too much in your answer. They only ask you to write the conditional checking if your $name variable is equal to Mike. Remove the $info = "Hi Mike"; bit and you should pass.