Let’s start with installing XAMPP, and running first PHP program using XAMPP Server on localhost. Following are the steps:

  • Download and Install XAMPP
  • Create a new project in XAMPP and add your PHP program
  • Open XAMPP and run your first PHP program

Download and Install XAMPP

Step 1: Go to the Apache Friends website and download XAMPP Server. Apache Friends is the official website to download XAMPP:

Step 2: After downloading, install it.

You can install it at any location. We installed XAMPP ic C: drive,

Create a new project in XAMPP

Step 3: Now, go to htdocs folder in Xampp folder and create your project folder.

Here, a folder DheerajProject created.

Step 4: Now, create a file with .php extension. We have created a file with name, FirstProgram.php.

Add the following code in it,

<!DOCTYPE html>

echo "My first PHP script!";


Open XAMPP and run your first PHP program

Step 5: Go to start button, and type Xampp Server to open it.

This will open Xampp Server- Control Panel. After opening it, just click Start on Apache to start the server:

Step 6: Now, go to the Web Browser and type, localhost/DheerajProject and press enter.

On pressing enter, you can see the following, locate your PHP file FirstProgram.php and click on it:

Step 7: Just press enter in the address bar,and you can see the output of your first PHP program FirstProgram.php:

Additional Reading