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 trialadam blevins
Courses Plus Student 2,285 Pointstrouble on stage 5 php basics conditions and loops
I am on task 3 of 3 in stage 5 PHP Conditionals and Loops. I was asked to create a variable name set to mike:
$name = "Mike";
Then an if statement:
if( $name == true){}
Now it wants me to echo "Hi, I am Mike" inside of the if statement. I thought I needed to delete the original if statement as above. Didn't work. Then I tried echoing under the if statement and that didn't work. In the video the instructor echo's a statement outside php block. I tried doing that as well and no good. Could someone explain this to me please?
8 Answers
Adam N
70,280 PointsTreehouse challenges generally build up on the previous code, so you shouldn't try deleting code as a way of modifying your answer.
You put what you want executed within the curly braces {}. Rewatch the video right before the challenge to see how the teacher is putting code in there.
Chris Malcolm
2,909 Pointsyou should check if $name == "Mike"
adam blevins
Courses Plus Student 2,285 PointsOk so this is what I did to pass the challenge. After coming up with a variable $name = "Mike"; Then the if statement if( $name == true){}, I had to backtrack under the first variable $name and put in a new variable titled $info = "Hi, I am Mike!" Once that was done I went back into the if statement, inside of the brackets , and echoed $info; So the end result looked like this:
1.<?php 2. 3.$name = "Mike"; 4.$info = "Hi, I am Mike!"; 5. 6.if( $name == true){ 7 echo $info;
- }
Thanks for the help guys!
George Akinian
17,615 PointsYo, This worked for me. Make sure there is a space between 'Hi, & I am'
<?php
$name = "Mike";
$info = 'Hi, I am'.' '.$name.'!';
if( $name == true ) {
echo $info;
}
?>
adam blevins
Courses Plus Student 2,285 Pointsapparently typing in php on screen comes out weird on a post smh
My name is Cash
12,489 PointsI tried everything to pass this challenge, and looked over all every forum I could find. The only thing that worked was what you explained, adam blevins in that order. Thank you!
Morgan Brutcher
3,350 PointsI also had to do what adam blevins did. The question needs to be reworded.
Maddalena Menolascina
6,668 Pointsfor me it passed the same as Paul Wagner, except I did my $info = "Hi, I am Mike!" ,no concatenation for me!