Hello my all dear Visitors, welcome again in this domain(www.bittutech.com). As we all know before, PHP is a server-side language which means your PHP script only runs on the Server machine, can not run on your web browser. But we can do something to run our PHP Script on our local machine. We have to need to install Servers on our local machine and run the PHP script with the help of those servers. Instead of downloading separate Servers, we can download a Server package at a time on our local machine.
Note-: All Web browsers like (Chrome, Mozilla, firefox, edge, e.t.c) are client-based web applications, and all Servers like (Apache, tomcat, e.t.c) are server-based web applications.
In this tutorial, First, we will look at How to download a Server on our local machine, then we will write a PHP script and run it on our local machine. before downloading the Server package, you can try the PHP script to be run on your web browser. You will look that Browser can not interpret your PHP script, simply your written words will be displayed on your browser window.
Don’t worry programmers, i will show you How the PHP web page looks like in the absence and in the presence of the Server.
Ok Programmers, it’s time to take a little break from downloading the Server package. You can download the most powerful and highly reliable server package. – XAMPP Server (Cross-Platform, Apache, MariaDB, PHP and Perl) Server.
Ok, so let’s get started and download the XAMPP Server with the help of any Internet browser or customized terminal window.
Step 1: Click the below link or type the XAMPP Server on your search engine
Table of Contents
Download For Windows OS
Download For MAC OS
Download for Linux OS
In XAMPP Server directory, sub-folder is also exist named as “htdocs”. This folder contains all PHP programs/files. This folder is also known as “public directory or root directory”.
After downloading and installing XAMPP Server, you will see the XAMPP Server (shortcut icon) on your desktop window or you can search “XAMPP Server” text by pressing Win+S key.
How to start the Apache Server?
Open the XAMPP Application and start the Apache Server, without starting the Apache Server, your PHP Script will not interpret.
When you want to use the mySQL database server, you can also start mySQL server. Pictorial representation of XAMPP Server application is given below.
How to create the First PHP Page?
After starting the Apache Server, you will have to write the PHP script on any text editor such as VSCode, Sublime text 3, e.t.c.
Open your text editor and type your simple PHP Script.
We can use a simple text editor(“Notepad”) only for this time because this is a simple PHP Script. We can write this Script without any text preferences.
File Name: FirstProgram.php
<?php echo "Hello World"; ?>
How to run your written PHP Script on your Web Browser?
After writing your PHP Script, save your PHP Script in the public sub-folder(htdocs). – Location – Drive:\XAMPP\htdocs\FirstProgram.php
Open your web browser and type in the URL Bar – localhost/FirstProgram.php or 127.0.0.1/FirstProgram.php and hit the Enter Key.
After hitting the Enter Key, you will see your Output, that is shown below.
In the above image, you will have see two major points. First is in URL Bar and second point is your PHP script has been interpreted on your web browser because of your localhost apache Server.
Last Words: Dear Visitors, this is the end of this PHP tutorial, we will meet very soon with the next PHP tutorial. I hope you will enjoy this tutorial and thank you so much for reading this tutorial till the end of the article. You can read other interesting tech posts through the right sidebar heading and you can follow us on social networks and also stay tuned with us as always.