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

cant echo mike?

Hi I'm not sure what im doing wrong?

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

1 Answer

Samuel Webb
Samuel Webb
25,370 Points

Remove 'php' before 'echo' and add a semicolon after $name.

Samuel Webb
Samuel Webb
25,370 Points

Since you're already inside of a PHP block, you don't need to write out 'php' before the echo statement. And make sure you end every statement inside of a PHP block with a semicolon. PHP is really strict about that.

Samuel Webb
Samuel Webb
25,370 Points

Actually, the test will still pass without a final semicolon. Your code can be either of the following:

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

or

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

I would suggest going with the second version since it's always good practice to end your statements with the semicolon.