Page 1 of 1

Problem with opening php files on localhost

Posted: Sun Mar 08, 2009 3:11 pm
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!

Re: Problem with opening php files on localhost

Posted: Sun Mar 08, 2009 7:17 pm
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.

Re: Problem with opening php files on localhost

Posted: Sun Mar 08, 2009 7:52 pm
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?

Re: Problem with opening php files on localhost

Posted: Sun Mar 08, 2009 8:01 pm
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?

Re: Problem with opening php files on localhost

Posted: Sun Mar 08, 2009 8:16 pm
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.

Re: Problem with opening php files on localhost

Posted: Sun Mar 08, 2009 10:43 pm
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.

Re: Problem with opening php files on localhost

Posted: Mon Mar 09, 2009 6:06 am
by ncarty97
OK thanks. I suppose I can just make a favorite or something.