Are HTML and CSS files necessary in the HTDOCS folder for PHP to work in XAMPP?

  • PHP
  • Thread starter Dave Ritche
  • Start date
  • Tags
    Php
In summary: 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.In summary, it is necessary to put your scripts in the HTDOCS folder if you want your browser to be able to access them. If you're using xampp, then it should work.
  • #1
Dave Ritche
70
6
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.
 
Technology news on Phys.org
  • #2
Dave Ritche said:
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.
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.
 
  • Like
Likes Dave Ritche
  • #3
Samy_A said:
Every file that the browser has to directly access must be in the HTDOCS folder or a subfolder of HTDOCS.

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:
 
  • Like
Likes Dave Ritche
  • #4
Dave Ritche said:
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.
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.
 
  • Like
Likes Dave Ritche

Related to Are HTML and CSS files necessary in the HTDOCS folder for PHP to work in XAMPP?

1. What is Xampp?

Xampp is a software package that includes all the necessary components for creating and managing a local web server. This includes the Apache web server, MySQL database, and PHP scripting language.

2. What is the purpose of the htdocs folder?

The htdocs folder is the default location for storing all the files that make up a website. These files include HTML, CSS, JavaScript, and PHP files. The web server will read and serve these files when a user accesses the website.

3. How do I access the htdocs folder in Xampp?

To access the htdocs folder in Xampp, you can go to the Xampp control panel and click on the "Explorer" button next to the Apache module. This will open the htdocs folder in your file explorer, where you can add, edit, or delete files as needed.

4. What is PHP and how does it work with Xampp?

PHP is a server-side scripting language that is commonly used for creating dynamic web pages. Xampp includes the necessary components to run PHP code on a local server, allowing developers to test their websites before making them live on the internet.

5. Can I change the location of the htdocs folder in Xampp?

Yes, you can change the location of the htdocs folder in Xampp by editing the Apache configuration file. However, it is recommended to keep the folder in its default location for easier management and compatibility with other software.

Similar threads

  • Programming and Computer Science
Replies
9
Views
870
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
21
Views
5K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
289
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
Replies
12
Views
2K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
6
Views
5K
Back
Top