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

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!