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 trialferdiepetalio
Front End Web Development Techdegree Student 7,532 PointsI've tested my code under workspace and it works. How come this doesn't work under challenge session?
<?php $name = 'Mike'; if( $name =='Mike'){ echo 'Hi, I am' . $name . '!'; } ?>
<?php
$name = 'Mike';
if( $name =='Mike'){
echo 'Hi, I am' . $name . '!';
}
?>
6 Answers
Kevin Korte
28,149 PointsBecause it want the sentence Hi, I am Mike!. Your code would echo Hi, I amMike!. Do you see the error, and thus the solution? You're so close.
ferdiepetalio
Front End Web Development Techdegree Student 7,532 PointsEven my version2 was not accepted.
http://port-80-8zf24qx83j.treehouse-app.com/test.php
<?php $name = 'Mike'; if($name == true){ //echo 'Hi, I am' .$name. '!'; $name = 'Hi, I am'.' '. $name . '!';
echo $name; } ?>
but anyway as long as i am absorbing and ending with correct results using workspace, that should be fine.
Kevin Korte
28,149 PointsYou're still not quite seeing it. You're missing a space in your echo statement. It wants am Mike, however you echo amMike. Thus your results is not passing. Do you see the error, and solution now?
ferdiepetalio
Front End Web Development Techdegree Student 7,532 Pointsunderstood of the solution and i see 2 ways of doing it. is this correct?
- $name = 'Hi, I am'.' '. $name . '!';
- echo 'Hi, I am ' . $name . '!';
as i undestand these 2 creates a space.
Kevin Korte
28,149 PointsSorry man, you're right, I got my eyes crossed when I looked at it. Yes, you are correct there. Because of the same reason I didn't catch your solution, option 2 would be the more human friendly way, and thus preferred way to add the space in the echo. But the computer doesn't really care either way....so good job!!
ferdiepetalio
Front End Web Development Techdegree Student 7,532 Pointsthanks Kevin. Now am learning!