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 Basics: Challenge Task 2 of 3

The task is too vague. There are numerous ways of determining if the string Mike.

index.php
<?php
$name = "Mike";
if( name = 'Mike'){
  $printname = "Mike"
}
else{
   $prntname =  "N/A" 
  }
?>

3 Answers

Because I found the instruction vague, I really try too hard with this and moved on about an hour ago.

Julian Gutierrez
Julian Gutierrez
19,201 Points

There is no need for an else statement or $printname in this challenge. In the if conditional you need to use the variable $name and check for equality by using a double equal sign rather than a single equal sign which is the assignment operator.

Tom Bedford
Tom Bedford
15,645 Points

Hi David

I've not looked at the challenge yet but I can see there is a typo in your code.

Inside else you use $prntname (missing the letter i) instead of $printname.

Does it work with that fixed?