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 Data & Structure PHP Variables

PHP Basics - Challenge 2

Part 1 asks to define a PHP variable name, for mike. Got that.

Part 2 asks me to echo mike to the screen - not sure what i'm doing wrong here? I've tried <?php echo "Mike" ?> and <?php echo $name ?> those exact lines of code work in my workspaces as I follow from the video...

What gives?

index.php
<?php 

$name = "Mike";

?>

<?php echo $name ?>

1 Answer

Erik McClintock
Erik McClintock
45,783 Points

Eric,

The challenge is failing because you created a second PHP code block for your echo statement, when it didn't want you to. It simply wants you to put the echo statement in the same code block that you created to house the variable for "Mike".

You have this:

<?php 

$name = "Mike";

?>

<?php echo $name ?>

And while, technically, that is not incorrect and would run just fine elsewhere, it will not pass the challenge here based on the checks that their system is making to see if you got the answer correct. You want:

<?php 

$name = "Mike";

echo $name;

?>

These code challenges can be very particular about what they will accept, so always try every little tiny thing to fix the errors, however stupid they might seem :p

Oh, and don't forget to add a semi-colon after your echo statement! Always officially end your statements!

Happy coding!

Erik

Thanks Erik!