Question:
Why do you have to make your php files in the htdocs folder?
?
2011-06-05 06:47:48 UTC
I'm kinda new to PHP and really don't know whats going on :P you have to run apache and all that stuff.. Also if i have to make it in the Htdocs folder how would i put it on my website?
Four answers:
Toad
2011-06-05 07:18:51 UTC
If you're running Apache that means you're using your local computer as your webhost. Because of security, by default Apache will only allow one local folder to be accessible from the internet. This is what htdocs is for. I believe this is defined in the httpd.conf file and can likely be changed.
Robin T
2011-06-06 17:44:40 UTC
The PHP file that you want to be accessed from the browser needs to reside in your htdocs folder. This folder can be changed / renamed if you want to. To do so, open the httpd.conf file in your Apache folder and search for 'DocumentRoot'. It should now have the path to your htdocs folder there. You can change it to whichever folder you choose.



After you go pass your beginner level you will find that you may have some PHP files that don't need to be accessible from the browser. For example, PHP scripts that deal with accessing the database, configuration, processing data, etc. So instead of having one PHP file dealing with everything it needs within that one file, you split the job to multiple scripts, each doing specific set of tasks. By doing so it allows you to reuse these scripts and when you need to change something in the future, you don't need to go through all your files and make the same changes to each of them, risking making human errors.



These PHP files that contain functions/classes that are simply being called by the browser-accessible files can be placed anywhere, preferably outside of htdocs (or whatever your DocumentRoot is).
Jin Cheng Teo
2011-06-05 07:07:16 UTC
I feel that you are actually on the right track. Apache is the web server 'that helps to deliver content that can be accessed through the Internet.'



Apache looks into the files located in the htdocs folder to process and put on the Web.



I got a feeling that you maybe hosting your webpages locally on your computer. You can access the webpage using the url : localhost/exampleFolder/exampleName.php
deonejuan
2011-06-05 06:57:14 UTC
If your ISP offers CMS websites, they will inform you of the costs and the folders concerning where the php files can be located. Your ISP probably has their folder named public_html.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...