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

narvesh pradhan
narvesh pradhan
2,958 Points

I am continuously trying to solve the challenge but still i m not done.

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";
}

?>

1 Answer

Lucas Santos
Lucas Santos
19,315 Points

You want this:

<?php
$name = "Mike";
if( $name == "Mike" ){
}
?>

The way conditionals work is like this:

<?php 
if( some condition is true ){
   // then do this code;
}
?>

Also notice how I used the equal sign twice and not one. That is because when you are checking if something is equal to something else you need 2 equal signs. One equal sign is used for whenever you want to set something to something else like so:

$age = 32;

just remember:

= is for setting == is for checking to see if values of something mach

Lucas Santos
Lucas Santos
19,315 Points

hey and also quick note if the double == does not work then try triple === to check if it is a "String" as well.