Please note, this is a STATIC archive of website www.simplilearn.com from 27 Mar 2023, cach3.com does not collect or store any user information, there is no "phishing" involved.

PHP is the most popular and widely-used server-side scripting language for web development. However, it requires a webserver to run even a locally developed webpage. There are various web server software for setting up our local webserver. Amongst them, PHP XAMPP and WampServer are the most popular. While WampServer is only available for the Windows platform, XAMPP is a cross-platform application that can run on Windows, Linux, and macOS. Hence, in this tutorial, you will learn PHP using XAMPP.

What is XAMPP?

XAMPP is an open-source web server solution package. It is mainly used for web application testing on a local host webserver.

XAMPP stands for:

X = Cross-platform

A = Apache Server

M = MariaDB

P = PHP

P = Perl

Now that you have a better understanding of the XAMPP software, let us move on to its installation. 

Basics to Advanced - Learn It All!

Caltech PGP Full Stack DevelopmentExplore Program
Basics to Advanced - Learn It All!

How to Install XAMPP?

Apache friends developed XAMPP, and it is available for everyone free of cost.

You can download XAMPP through the official website, https://www.apachefriends.org/download.html.

On completing the download of the setup file, begin the installation process and, in the “Select Components” section, select all the required components.

XAMPP_1

Next, select the directory where you want the software to be installed. It is recommended that you keep the default directory “C:\xampp” and click on “next” to complete the installation.

XAMPP_2

Now that the installation is complete, let’s move ahead to see how to run a PHP script using the same.

Learn the Ins & Outs of Software Development

Caltech Coding BootcampExplore Program
Learn the Ins & Outs of Software Development

How to Run a PHP Code Using XAMPP?

Before running a PHP script, you must know where to write it. 

In the XAMPP directory, there exists a folder called “htdocs”. This is where all the programs for the web pages will be stored.

Now, to run a PHP script:

1. Go to “C:\xampp\htdocs” and inside it, create a folder. Let’s call it “demo”. It’s considered good practice to create a new folder for every project you work on.

XAMPP_3

2. Inside the demo folder, create a new text file and name it “index.php” and write the following script.

XAMPP_4.

3. Now, to see the script output, open the XAMPP control panel and start Apache to host the local webserver, where our script will be running.

XAMPP_5

4. Now navigate to your browser and type in “localhost/demo/” in the address bar to view the output.

/first_php_script_xampp_6

Congratulations, with this, you have created a PHP file and also executed the program successfully. 

Learn right from the basics of JavaScript to advanced concepts of Angular, Spring Boot, Hibernate, JSPs, MVC, etc. Enroll in our PGP in Full Stack Web Development today!

Conclusion

This concludes the tutorial. In this “PHP using XAMPP” tutorial, you looked into why you need XAMPP, what XAMPP is, how to install XAMPP, and finally, how to run your first PHP script on it.

Are you planning to take the plunge and do a course on PHP? In that case, Simplilearn’s PHP course would be an excellent choice. The Post Graduate Program in Full Stack Web Development  covers all the fundamental and advanced concepts, making your journey towards learning PHP an easy one.

If you have any questions regarding the “PHP using XAMPP” tutorial, please ask away in the comments section of this article, and we’ll have our experts answer them for you.

Happy Learning!

About the Author

Ravikiran A SRavikiran A S

Ravikiran A S works with Simplilearn as a Research Analyst. He an enthusiastic geek always in the hunt to learn the latest technologies. He is proficient with Java Programming Language, Big Data, and powerful Big Data Frameworks like Apache Hadoop and Apache Spark.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.