...

View Full Version : Can PHP Include a "Local" File?



jakerbug
02-23-2007, 09:47 PM
I know this is probably a very dumb question with a very easy answer (and yes, I did Google it - it's probably just so self explanitory that no one's ever had the occasion to ask before...):

Can I reference a file on my local hard drive as a PHP "include?" I realize that simply by virtue of the fact that PHP is a server-side languge, the answer is probably "no," but I like to be told "no" rather than just assume it.

The guts of the file I'm working on live on my local machine, and I just need to get it through the PHP script on the server... Rather that go through the extra step of uploading the file to the server and then running it through the PHP script, I just thought it would be nice if I could cut out that middle step.

ptmuldoon
02-23-2007, 10:03 PM
Why not install a WAMP client?

//http://www.wampserver.com/en/


I do all my testing locally on my home pc. The above is the one I use, and works very well for my needs.

Fou-Lu
02-24-2007, 12:04 AM
Doesn't quite answer the question, but you're right.

Includes can be used on your local system only if it is also the server system. Any other computer that hits your server will not be able to include a file from their filesystems unless you allow them to upload them (which is a very very very bad idea).
So... yes, the server computer can access any resource of itself. But it cannot access any resource from a client computer.

And definitly install a system on your local computer for testing and development. I don't recommend the use of any predefined packages, but they mainly work. I've had nothing but trouble with them, so I would just drop an apache/php/mysql system, or if your on windowsxp pro or better, you can enable your IIS server and configure it with php and mysql or another database of your choice.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum