Where to Place PHP Files in XAMPP

In this quick article, we will discuss where to place PHP files in XAMPP and how to access them from the browser.

Install XAMPP

If you haven't installed XAMPP then use the below link to download and install the same:

https://www.apachefriends.org/download.html

Where to Place PHP Files in XAMPP?

The main directory for all WWW documents is \xampp\htdocs

For example, if you have chosen the "c:\axmpp" as the target folder while XAMPP installation then here is the complete path where you need to store PHP files:
C:\xampp\htdocs
The below screenshot shows the location where you keep PHP script files.


How to Access PHP Files from Browser

Let's create a simple PHP script file "test.php" with the following code into it:

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>

</body>
</html>
Keep the above "test.php" file within "C:\xampp\htdocs" location:

Use the below link to access this PHP script from the browser: http://localhost/test.php

If you want to create a new folder "new" within "C:\xampp\htdocs" and keep all the PHP files then you need to those files using the below URL in a browser:

Comments