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

What does echo a name to the screen mean in PHP?

Code challenge question is vague. Don't know if it means to add php code or to include php within HTML for a particular section of code. I need to understand what "to the screen" means within the question, "Now echo Mike's name to the screen."

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

2 Answers

Grace Kelly
Grace Kelly
33,990 Points

Hi Christopher, echo simply means to output something to the screen, in this case the $name variable. In order to echo out something we do the following:

<?php
echo $name;
?>

This will output the name Mike to the screen.

Hope that helps!!

Thanks your Highness:), that helped alot. Some of the questions in the challenges are pretty vague, and some assume more background knowledge than the student has at the time.

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi there Christopher.

Echo is the equivalent in JavaScript of `document.write.... of simply displaying something to the browser page. Which could be a string or a number of any php datatype.

<?php
$name = "Mike"
<?php echo = "Mike";
  ?>

All this code does, is prints the string Mike, on a web page.