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

trouble 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

Treehouse 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
Chris Malcolm
2,909 Points

you should check if $name == "Mike"

Ok 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;

  1. }

Thanks for the help guys!

Yo, This worked for me. Make sure there is a space between 'Hi, & I am'

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

apparently typing in php on screen comes out weird on a post smh

My name is Cash
My name is Cash
12,489 Points

I 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
Morgan Brutcher
3,350 Points

I also had to do what adam blevins did. The question needs to be reworded.

Maddalena Menolascina
Maddalena Menolascina
6,668 Points

for me it passed the same as Paul Wagner, except I did my $info = "Hi, I am Mike!" ,no concatenation for me!