Problem with opening php files on localhost

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
ncarty97
Forum Newbie
Posts: 6
Joined: Mon Oct 27, 2008 1:07 pm

Problem with opening php files on localhost

Post by ncarty97 »

I did a search, but didn't find any answers so hopefully someone has an idea what is wrong with my set up.

I'm using php 5.2.6 and Apache 2.2 as I work my way through the PHP & mySQl for Dummies book.

I've saved a couple php files in the htdocs folder that Apache looks at for php files.

If I type in the URL bar in Firefox: localhost\test.php, it works great. However, if I type in:
"C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/test.php"
or open up the folder and double click on the test.php file, I get a blank page with a box asking me what application to open the file with.

My Apache config file has the following setting activated:

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

so as far as I can tell, it is set correct.

Is there something I am missing?

Thanks!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Problem with opening php files on localhost

Post by califdon »

It's operating the way it's supposed to. When you specify a FILE in a browser, it does not use a web server at all. You can do that on any computer, even without having a web server installed. Now, PHP requires a web browser (like Apache) to parse and execute the PHP code, so of course it won't do that when you refer to a FILE instead of the web server, which is what you do when you refer to localhost.
ncarty97
Forum Newbie
Posts: 6
Joined: Mon Oct 27, 2008 1:07 pm

Re: Problem with opening php files on localhost

Post by ncarty97 »

Ok thanks.

Is there any easier way to open a php file in a browser without typing in the location in the address bar?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Problem with opening php files on localhost

Post by Benjamin »

ncarty97 wrote:Ok thanks.

Is there any easier way to open a php file in a browser without typing in the location in the address bar?
Umm, with your PHP editor?
ncarty97
Forum Newbie
Posts: 6
Joined: Mon Oct 27, 2008 1:07 pm

Re: Problem with opening php files on localhost

Post by ncarty97 »

I'm just using conText for php editing, so it doesn't run the programs. I was going to play around with a trial version of phpED, but not sure I'm going to shell out the money for it.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Problem with opening php files on localhost

Post by califdon »

ncarty97 wrote:Ok thanks.

Is there any easier way to open a php file in a browser without typing in the location in the address bar?
Let me try again: PHP is a scripting language that is parsed and executed by a web server. That's its purpose, in order to serve dynamic documents to browsers. Not only is there not an easier way to execute PHP, there is no other way than by using a web server.
ncarty97
Forum Newbie
Posts: 6
Joined: Mon Oct 27, 2008 1:07 pm

Re: Problem with opening php files on localhost

Post by ncarty97 »

OK thanks. I suppose I can just make a favorite or something.
Post Reply