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

Workspaces PHP

I'm trying to replicate the Stripe API and PHP workshop code, however I'm running into an issue on the workspace when I choose PHP, and view the code it just gives me an index page which my file to download, http://awesomescreenshot.com/0143e6l269

I tried commenting out everything else and just doing the basic 'Hello World'; script which if I'm not mistaken is just this:

<?php Echo 'Hello world';

What could I be doing wrong?

6 Answers

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

Hi Ron Arevalo ,

In order for PHP files to be rendered, you'll have to build them in a workspace based on a PHP environment. You can choose the option for the type of workspace when first creating the workspace.

Regards,

Nathan

I did choose a PHP environment.

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

hmmm... looking at your code, you want to switch up 2 things:

  • close the php tag with ?> at the end of the php code
  • de-capitalize echo

i tested the following, which worked for me in a PHP-workspace:

<?php echo 'hello world'; ?>

also, since you didn't mention one way or the other, your filename in the workspace has to end in .php.

Hope that helps!

Just a tip; neither of these things matter.

PHP doesn't need a lowercase for "echo", I have tested this again to be sure and you can do "Echo 'Hello, world';" - however this does break highlighting in the workspace.

PHP also doesn't require the <?php tag to be closed upon opening (unless you're using a HTML document at the same time).

<?php
  Echo 'Hello, world';

The above code is fully tested and working, however it looks nicer to have a lowercase e when starting the Echo function. The below code does look neater:

<?php
  echo 'Hello, world';
?>

but this isn't required :)

I can definitely see that yours is working, however this is what happens when I try it: https://www.evernote.com/shard/s284/nl/39737686/a70f1571-32cc-4856-9470-7726f90e80a9?title=Untitled

One think I do notice is that my work space reads "static" even though I have chosen PHP: Static

Each time I create one, it always reads static, I choose "environment" to be PHP. Disregard that there's no name to the space for now. Also thanks so much for all the help. New PHP