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

Michael Quirke
Michael Quirke
3,185 Points

PHP, Shirts 4 Mike site, php code won't work but html does

Hi guys

I've just started the 'Build a Simple PHP Application' tutorials, and am working my way through the end of the first badge. I'm not sure why but the php code won't recognize when I try to use the 'date' function. The code for the tutorial 'Your first php file' where we input the date function to automatically update the year on the copyright tag is :

<p>&copy;<?php echo date('Y'); ?> Shirts 4 Mike</p>

All the browser recognizes is the html code, which all gets printed out correctly but the php code doesn't. I have put in the correct paragraph p tags as well, though they won't show up in the code above for some reason.

I've followed along with the video and input everything as is, the file is saved as .php in sublime text 2, it was installed/saved correctly etc. so not sure what's going on?

Any help on this would be much appreciated!

Cheers

I'm having the same problem. I've already tried running it from localhost. I'm not seeing any changes in page however. These are the changes I've made to the code. <title><?php echo "Shirts 4 Mike"; ?></title>

and

<p>Ā©<?php echo date('y'); ?>2012 Shirts 4 Mike</p>

Any help would be greatly appreciated.

2 Answers

Michael Quirke
Michael Quirke
3,185 Points

Hey never mind just saw it works now if I actually load the file directly from the server localhost, as opposed to just dragging the file into the chrome browser to view it, which I was doing earlier.

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Glad you got it working, Michael! Because PHP code gets executed on the server, you do have to access it through a server address like localhost. Good luck with the tutorials!