PHP is a server-side language and it cannot run without a server. XAMPP provides Apache (server), PHP, and MySQL together. Apache must be running to execute PHP files on localhost.
👉 If running php -v shows any error, you must install PHP properly. Follow one of the guides below:
🎥 Video Guide:
PHP Installation Guide (YouTube)
🌐 Step-by-step Article:
Install PHP Using XAMPP (Website)
In this tutorial, you will learn how to check PHP installation, create a PHP project folder, write PHP code, start Apache & MySQL servers, and run a PHP project on localhost.
Video Tutorial
Step 1: Check PHP Installation
Open Command Prompt and run the following command to verify PHP installation.
php -v
Step 2: Create Project Folder
Navigate to the XAMPP htdocs directory and create a new folder named newproject.
C:\xampp\htdocs\newproject
Step 3: Write Your First PHP Code
Inside the project folder, create a file named index.php and write the following PHP code.
<?php
echo "Hello PHP";
?>
Step 4: Start Apache & MySQL
Open XAMPP Control Panel and start Apache. MySQL is optional for this project but recommended.
Step 5: Run PHP Project
Open your browser and enter the following URL.
http://localhost/newproject
If you see Hello PHP, your PHP project is running successfully 🎉
Now that you have built your first PHP project, the next step is to learn PHP variables, forms, conditions, loops, database connection using MySQL, and real-world PHP projects.
👉 To continue learning PHP in a structured way, visit: PHP Programming Fundamentals
What is XAMPP?
XAMPP is a free local server software that includes Apache, PHP, and MySQL.
It allows you to run PHP projects on your computer without the internet.
Why do we need XAMPP for PHP?
PHP is a server-side language and cannot run directly in a browser.
XAMPP provides Apache server which is required to execute PHP files.
Where should PHP projects be created?
All PHP projects must be created inside the htdocs folder
located at C:\xampp\htdocs.
What is index.php?
index.php is the default file that loads automatically
when you open a PHP project in the browser.
What if php -v shows an error?
If php -v shows an error, PHP is not installed or configured properly.
You should install PHP using XAMPP.
How to open a PHP project in browser?
Start Apache server and open:
http://localhost/project-folder-name
Is MySQL required for PHP?
MySQL is not required for basic PHP projects,
but it is required when working with databases.
What should I learn after this?
You should learn PHP variables, forms, conditions, loops,
MySQL database connection, and real-world PHP projects.