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

index.html to index.php issues

When I changed the extension of my index file from .html to .php it wont appear in my localhost any longer? I can see test.php but not index.php? Any ideas why this is happening?

8 Answers

Hey! Thanks for your help...

I am using Mamp, the file has been saved and it is in the htdocs directory. For some reason it will load a blank page in the broswer :(

Please post your php file code here by using three backticks followed by the word php (under esc on mac). Put the code on the next line and on the very bottom underneath the code put three more backticks. Us the markdown cheatsheet if you are confused.

Yeah there might be a code problem, php isn't forgiving at all if you make a mistake, whereas html will still load the page. But it didn't give you any php warnings or errors, which is weird.

Exactly and even if you just forget a semicolon on a PHP statement, there is a good chance you are going to get a white screen. Otherwise it will show up white if there is actually no content in the html and only contains page structure.

That is pretty weird.

Couple quick thoughts:

Are you using Xamp or Mamp for your localhost server and have them started up? Is your index.php in the htdocs directory? Did you save your file after changing the name and trying to refresh?

Sorry I couldn't be more help, this hasn't ever happened to me.

Good luck.

Hey! Thanks for your help...

I am using Mamp, the file has been saved and it is in the htdocs directory. For some reason it will load a blank page in the broswer :(

When you go to your browser and type in localhost do you get anything besides a blank screen? I'm assuming, yes, you get test.php?

If I put the file in a folder, I can see the folder in my local host. If not then it just registers a blank screen :(

Hi Marc,

MAMP will automatically run the index file in it's top most directory under htdocs. It's totally natural to see the parent directory if you don't have an index file right in the htdocs directory. Just click on the folder you added the index.php file to and it should load it up. This is how I use my localhost.

Thanks Tom,

Yeah I have been using it the same way. If I put my index.php file in the folder with its other assets, I will first see that folder in my local host. When I click that folder in my local host, the browser auto detects (im assuming) index.php and loads that page. When this happens, the browser returns a blank screen with no information on it (and the index file is full of information). Does that make sense?

On the other hand, if you type localhost into your web browser and get a blank screen then most likely you haven't started up the Apache server in MAMP.

Do you mean you can't see it in the web browser listing i.e. http://localhost:8888, or do you mean you can't see it in the file management i.e. windows explorer or mac finder ???

Try typing in the direct URL in a web browser to see if the index page appears.

In your file management system you might need to 'show hidden files' and see if that works.

I should also add that index.html work great, but AS SOON as I switch it over to index.php, it generates a blank landing page...

:(

Ugh, that was it! I had a colon instead of a semi-colon... thanks everyone for your help. I guess this is a good lesson in the sensitivity of php

Ha figures. It happens all the time. Don't sweat it! Glad it's working.

Glad you got it working!