Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2004
    Location
    New Jersey
    Posts
    70
    Thanks
    2
    Thanked 1 Time in 1 Post

    Can PHP Include a "Local" File?

    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.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts
    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.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •