Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Xampp, php and htdocs folder

  1. Jan 29, 2016 #1
    Hello everyone..
    I am learning php and i'm new to php.I don't know much about it.
    i watched a tutuorial on it that told me i were to put my scripts into the HTDOCS folder.
    My question is that is it necessary to my html and css files into HTDOCS folder?Will it work?
    I am running xampp..
    thanks.
     
  2. jcsd
  3. Jan 29, 2016 #2

    Samy_A

    User Avatar
    Science Advisor
    Homework Helper

    Every file that the browser has to directly access must be in the HTDOCS folder or a subfolder of HTDOCS.
    This applies to a php file that the url refers to.
    Also, if your HTML includes statements like:
    HTML:
    <script src="/somepath/js/directives.js" type="text/javascript"></script>
    <link href="/somepath/css/standard.css" rel="stylesheet" type="text/css"/>
    then the referenced folders must exist in HTDOCS.

    Your can rename the folder (my WAMP version uses www).
    Your php code can access files in folders outside the HTDOCS folder. But the browser can't.
     
  4. Jan 29, 2016 #3

    jtbell

    User Avatar

    Staff: Mentor

    I'll just add that this is for security reasons. If you made your server accessible to everyone on the Internet (it may actually be that way depending on how your Internet connection is set up!) would you want them to be able to look around everywhere on your hard disk by entering a suitable URL? :wideeyed:
     
  5. Jan 29, 2016 #4
    htdocs is by default set up as your main virtual directory, you can modify your apache server config file to resolve your url to anywhere that your resources are being stored physically. That means you can store your php scripts in the same folder with your html and css. You'd better learn to use a php framework though.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Xampp, php and htdocs folder
  1. PHP Help ? (Replies: 16)

  2. Php or c++ ? (Replies: 40)

  3. Advise: PHP or Java (Replies: 9)

  4. Understanding PHP (Replies: 4)

Loading...