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 If / ElseIf Conditionals

Jeremiah Wodke
Jeremiah Wodke
3,192 Points

? about Quiz question: Finally, echo the following string inside of the if statement: 'Hi, I am Mike!'

Why is this wrong? I've tried so many different things. Somebody please help, this is driving me nuts!

<?php

$name = "Mike";

if( $name == FALSE ) { $name = 'Hi, I am Mike!'; echo $name;

}

?>

Jeff Lemay
Jeff Lemay
14,268 Points

Copied for formatting:

<?php
$name = "Mike";

if( $name == FALSE ) {
    $name = 'Hi, I am Mike!';
    echo $name;
}
?>
Jeremiah Wodke
Jeremiah Wodke
3,192 Points

<?php $name = "Mike";

if( $name == FALSE ) { $name = 'Hi, I am Mike!'; echo $name; } ?> Quiz says this answer is invalid. To be honest, I'm questioning whether the Quiz is just erroneous & my answer is actually correct.

1 Answer

Jeremiah,

Don't know why you have FALSE inside of your IF statement. The challenge asks you to see if the variable is equal to 'Mike' not FALSE. Replace the FALSE with Mike. Also, the challenge asks you to echo out the phrase not assign it to the variable. While you can syntactically do that, the challenge doesn't ask you to do that just echo the phrase using the echo keyword.

Cheers!

Jeremiah Wodke
Jeremiah Wodke
3,192 Points

Thanks Shawn, I'm still a rookie but your explanation cleared everything up for me! I appreciate it.

Kah Chun Chiang
Kah Chun Chiang
917 Points

I still can't get it to work. $name = 'Mike'; $info = 'Hi, I am Mike!'

if ($name == 'Mike'){$info = "Hi, I am Mike!";}

Jeff Lemay
Jeff Lemay
14,268 Points
<?php
$name = "Mike";

if( $name == "Mike") {
    echo "Hi, I am " . $name . "!";
}
?>