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 trialDaniel Schwemmlein
4,960 Pointsif statement still won't work
It asks me for the following things: create a string named mike. so thats $name='Mike'; then it asks me to create an if statement to test if the value of the string is mike. that should be:
if ($name='Mike') {
}
they didn't ask me to display anything in the curly braces. So i haven't put anything in there. Does treehouse have a fix now for this bug?
7 Answers
Alex Heil
53,547 Pointshey guys, for clarification: in fact you're ALL right ;)
with single equal you're assigning a value
$name = "Mike";
and with the double equals you're checking a value
if ($name == "Mike") {
//do something
}
however, even with the correct code currently the challenge will give you an error back - that's unfortunately a known issue and was already reported to the team, so currently there's no way to complete the challenge.
Erik McClintock
45,783 PointsDaniel,
The issue here is in what you're trying to check inside your if statement. Currently, you're using one equals sign, which is used for assigning values. You need to use at least two equals signs, which is the operator used to check equality. To illustrate:
You currently have this:
if($name = 'Mike') {
}
That has one equals sign, thus you're trying to assign a value to a variable. This is not what we want inside a conditional check. Rather, you want:
if($name == 'Mike') {
}
...and then you should be good to go!
Hope this helps!
Erik
Hugo Paz
15,622 PointsHi Daniel,
I fixed your post so we could see your code better. You have an error in your code. You want to compare if $name is equal to "Mike". To compare you use double equals.
One equal is used to attribute a value to a variable. Hope this helps.
Rich Bagley
25,869 PointsHi Daniel,
Try using:
if ($name == 'Mike') {
}
instead of the following to compare:
if ($name='Mike') {
}
Thanks -Rich
Michael Jurgensen
8,341 PointsHi Daniel,
This challenge seems to be bugged. I typed the following code in the challenge:
<?php
$name = "Mike";
if($name == "Mike"){
}
?>
I get an error : Cannot see if statement. The treehouse team needs to be notified of this.
Daniel Schwemmlein
4,960 Pointsstill won't work. even with 2 equal signs
Daniel Schwemmlein
4,960 Pointsso just to be clear i put $name = "Mike"; if ($name =="Mike") {
} And i get the error "I can't see your if statement"
Hugo Paz
15,622 PointsDaniel check Alex answer. At this stage there is a bug with this challenge. That is the correct answer.