Installation of XAMPP

What is PHP and used for?

Since PHP is a backend programming language, so we need a piece of software to run and execute its code. we cannot just simply write our code in some text editor and expect it to be run on some browser.

To do that we need software called XAMPP (Cross, Apache, MySQL, PHP, Perl), developed by Apache Friends, for different platforms.

XAMPP helps the developers to create and test their programs on a local webserver.

*There are different versions of PHP which have been released till now. (PHP 7.4, PHP 7.2, PHP 7.3). The latest one is PHP 7.4, though you can use any version amongst listed above. *

So here is a quick installation guide to install PHP in your system.

*(You have to be careful with every command to run XAMPP successfully.)

  • Search on your browser Download XAMPP. then click on the website link shown in the image. The link will directly take you to the official website of XAMPP from where you can install the software. Go to XAMPP Website.

*Now at this window, Click on any version according to your WINDOWS, LINUX, or MAC OS X operating system.

  • After downloading, look for your file in ‘c:\drive’. Double click on the XAMPP folder or you can right-click on your folder and click open. Then click YES to your next window and allow this software to make changes in your computer system.
  • At this window click NEXT.
  • After checking all the options. Click on NEXT.
  • You can choose a location where you want to save your XAMPP folder. Choose the default location and click NEXT.
  • Click NEXT.
  • Now your setup is ready to install. Click NEXT.
  • Choose your preferred language.
  • Click on FINISH.
  • Choose your preferred language.
  • Now click on the start button for both the Apache server and MYSQL server.
  • If no error has occurred then your window will look like this and your XAMPP is ready to run.

How to run PHP program in XAMPP

You are going to write your 1st PHP program. Hurray! Are you ready? So, let’s get it.
We use to write our code and echo command to print the output on a local server.

Before starting your program 1st, you need to start both files of apache and MySQL server in the XAMPP control panel.

After that: –

  • Open your text editor. Type below code in your editor. You don’t need to understand the code now. We will discuss this in later chapters. Just type this code and run it on a browser as explained.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>My PHP code</title> </head> <body> <? Php // your code here $a= “Hello World!”; //the ‘a’ is a variable here which has to be defined first echo $a; //echo is used to print the output on screen ?> </body> </html>
  • Here we have used Sublime text editor to write our code.
  • After writing the code press ctrl+S to save your file. Give some name to your file example ‘myFirstcode.php’ and click on local disk c: then click on the htdocs folder and open it. Now save your file in this particular folder for better access to XAMPP(remember to save your file with ‘.php’ extension. Otherwise your file will not run on your local server).
  • After saving your file, open any of your browsers. But it will be better if you use Google chrome as we also have to embed HTML code later. Because some HTML tags don’t run on other browsers but they are supported by chrome properly.
  • Now on the search bar type http://localhost/myFirstcode.php (remember to start your XAMPP control panel first).

Congratulations! You have written your 1st PHP program.

Installation of XAMPP
Show Buttons
Hide Buttons