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 trialWiktor Głowacki
699 PointsHi looks like I found a bug in challenge test
Hi, my challenge is: Under the variable $name create a if statement that test to see that the $name variable is set to the string 'Mike'.
so my code is:
$name = 'Mike';
if ($name = "Mike"){
}
but course checker is saying: Bummer! I cannot see your 'if' statement.
Is this a bug?
4 Answers
Erik McClintock
45,783 PointsWiktor,
There has been a bug on this challenge, but currently, you have an error in your code. You are currently using one equals sign in your IF statement, which is what you use to assign a value, not to check equality between two values. You need to replace the single equals with a double or triple equals sign in your code to have the correct answer.
if($name == 'Mike') {
}
//or
if($name === 'Mike') {
}
Try adding an equals sign and see if you pass. If you don't, then the bug is still present on this challenge.
Erik
Wiktor Głowacki
699 PointsThanks Erik
I did try with two equals sign but there was the same error displayed. What I just discovered now is:
- I typed if($name=='Mike'){} - chalenge passed
- I typed if ($name=='Mike'){} - chalenge failed
- I removed space between if and ( and recheck challenge - failed again
Jason Anello
Courses Plus Student 94,610 PointsHi Wiktor,
I thought maybe you found the secret but I can't duplicate your results. Anyway, I don't think the challenge should require that it's all placed on one line.
This challenge and the foreach
one which you've already discovered are currently down.
The staff are working on it.
Wiktor Głowacki
699 PointsThe same story on loop challenge:
Using a foreach, create a loop that goes through each of the names in the $names array.
Bummer! I do not see a foreach statement
<?php $names = array('Mike', 'Chris', 'Jane', 'Bob'); foreach($names as $name) { } ?>
Gelson Luiz Sabino Junior
3,153 PointsIt is no bugged.
The RIGHT answer is:
<?php
$name = "Mike";
if($name == "Mike") { echo "Hi, I am " . $name . "!"; }
?>