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

fernando anderson
fernando anderson
4,781 Points

I don't understand why this isn't working; I've tried "<?php echo $name; ?>" but its telling me I'm doing something.

I've tried echoing with and without html and also inside the php tags but it telling me I'm doing it wrong. I can't think of anything I'm doing wrong can anyone help.

index.php
<?php  $name = "Mike"; ?>

<!DOCTYPE html>
<html>
<body>

<?php
echo $name;
?>

</body>
</html>

2 Answers

Damien Watson
Damien Watson
27,419 Points

Hey Fernando,

They don't expect you to put the html elements in, so just the php part:

<?php $name = "Mike"; ?>
<?php echo $name ?>
fernando anderson
fernando anderson
4,781 Points

Thanks, I must have typed something in wrong; because I tried that one first. Thanks again for putting me on the right track and helping me understand the assignment.

Damien Watson
Damien Watson
27,419 Points

Your welcome, glad you're back on track. I'm just jumping through this course now as well. :)