Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics (Retired) PHP Data & Structure PHP Variables

Malin Spindel
Malin Spindel
154 Points

Why does this not work? <?php $name = "Mike"; echo $name ; ?>

why does this not work?

I typed out exactly what you have entered above (<?php $name = "Mike"; echo $name; ?>) into a file called testit.php, then saved that page.

I then started XAMP (I am running windows)

I then accessed that page (testit.php) by using the URL address: http://localhost/testit.php

And got this output on the web page:-

Mike

1 Answer

Torger Angeltveit
Torger Angeltveit
11,228 Points

Hi malin, There is nothing wrong with the code.
do you use a domain or have a fake hosting installed to read the php code?

Malin Spindel
Malin Spindel
154 Points

I deleted the spaces before the statements and then it was aprooved! wierd! But thank you for your answer!