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.
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.
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.
Now that the installation is complete, let’s move ahead to see how to run a PHP script using the same.
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.
2. Inside the demo folder, create a new text file and name it “index.php” and write the following script.
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.
4. Now navigate to your browser and type in “localhost/demo/” in the address bar to view the output.
Congratulations, with this, you have created a PHP file and also executed the program successfully.
Looking forward to becoming a PHP Developer? Then get certified with the Advanced PHP Development Course. Enroll now!
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 PHP certification covers all the fundamental and advanced concepts in PHP, 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.