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

Ray Edison Refundo
Ray Edison Refundo
3,798 Points

Finally, echo the follow if statement 'Hi, I am Mike!'

hello what is wrong with my code ?

<?php $name = 'Mike'; if ( $name == 'Mike'){

$name = 'Hi, I am Mike!';

}

?>

index.php
<?php
$name = 'Mike';
if ( $name == 'Mike'){

  $name = 'Hi, I am Mike!';

}

?>

2 Answers

jason chan
jason chan
31,009 Points
<?php
// you define the variable mike
$name = 'Mike';

// if the name is equal to Mike (true)
if ( $name == 'Mike' ){

// print Hi i am the Mike[name]
  echo 'Hi, I am ' . $name . '!';

}
?>
Stanley Thijssen
Stanley Thijssen
22,831 Points

You didnt use echo to echo out your variable for example:

<?php
$name = 'Mike';

if ( $name == 'Mike' ){

  echo 'Hi, I am ' . $name . '!';

}
?>