First you need to start XAMPP. So, go to the drive where you install the XAMPP server. Generally, it's installed in C drive. So, go to C:\xampp\ . And open the file xampp-control.exe . When the controller open you need to start the Apache and Mysql . Then you see the green color besides Apache and Mysql . It means they are running or started. OK.
Now, go to C:\xampp\htdocs and create a folder as you want. For an example you can create folder which name is hello . Then open this folder and create a file which name is index.php and open it in you editor write a basic code like this:
<?php
echo "Hello World";
?>
Then save it. And open your browser. And go to localhost/hello
hello means the folder name you created.
Now, you will see the output. Which showing Hello World
Feel free to asking any question. Happy Coding!!
Answer from acoder on Stack OverflowFirst you need to start XAMPP. So, go to the drive where you install the XAMPP server. Generally, it's installed in C drive. So, go to C:\xampp\ . And open the file xampp-control.exe . When the controller open you need to start the Apache and Mysql . Then you see the green color besides Apache and Mysql . It means they are running or started. OK.
Now, go to C:\xampp\htdocs and create a folder as you want. For an example you can create folder which name is hello . Then open this folder and create a file which name is index.php and open it in you editor write a basic code like this:
<?php
echo "Hello World";
?>
Then save it. And open your browser. And go to localhost/hello
hello means the folder name you created.
Now, you will see the output. Which showing Hello World
Feel free to asking any question. Happy Coding!!
make sure your apache service on your XAMPP is running, if you using database, activate mysql too.
and save your file in C:\xampp\htdocs
if your file index.php, you can access it as localhost/index.php
if you make folder inside htdocs like C:\xampp\htdocs\test
you can access it as localhost/test/index.php
Videos
Can we run PHP in XAMPP?
Q1. How to run PHP file in XAMPP on Windows?
Q8. Why is my PHP file not running in XAMPP?
If I try to put a php file inside any other location other than whats listed in the title, it just shows the code and doesnt execute it. Is there a way around this?
If lampp is not already running start it from a Terminal crtl + alt + t type:
sudo /opt/lampp/lampp start
Then open a browser and go to the url localhost/yourFile.php.
Replace yourFile.php with the name of your php file.
Or name the php file index.php and just enter localhost in the browser.
firstly you will have to start the local host as mentioned
sudo /opt/lampp/lampp start
you will see the output on the termminal saying
Starting XAMPP for Linux 7.1.9-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
you will have to check the permissions given to htdocs folder to make life simpler try this
cd /opt/lampp
this will redirect you to the lampp folder , here change the permission of the document root , i.e permissions of htdocs
sudo chmod 777 htdocs
go into the folder
cd htdocs
now make your own document root file to store all your files
mkdir yourfoldername
now it is as simple as copying the files into this folder , now open your browser and type in
-> in your browser localhost
you will see -> localhost/dashboard/ remove the dashboard part and replace with
-> localhost/yourfoldername
and here click on the file you put inside the folder you had made in htdocs , and there you go . you can run the php file from here