What is PHP?
PHP - Hypertext Preprocessor is a server-side scripting language that runs on the servers like IIS, Apache. It is the topmost and widely used scripting language to build web portals and blogs. PHP is loosely coupled about data types. As PHP is an open-source scripting language, it is very easy to learn and experiment in our local desktop or laptop computer.
Why do we need to learn PHP?
As we are living in the computer age and slowly moving to the mobile world, there is a need for web application developers and API developers around the globe. The topmost websites like Facebook, Wikipedia, Yahoo, Flickr, Tumblr, Friendster, Sourceforge are built with PHP Script. i.e More than 75% of the websites in the globe are powered by PHP. Now you can understand the power of PHP!
Ready to code with PHP?
As the first step to learn PHP, We must have some set of software to be installed on our computer. If you are using windows operating system then you can use WAMP , XAMPP. In this tutorial, we are going to use the WAMP server. This WAMP server includes PHP, MySQL, Apache server together as a single bundle. Once you have installed WAMP server, start the WAMP server by double-clicking from the Windows start menu. Further, we will split the basic learning with 3 steps as follows.
Step - 1
Before going to the first step we will see some basic information about PHP. The PHP extension usually ends with .php and the current stable version of the PHP is 7.3.6 as of 30 May 2019.
Open C:/wamp/www or some times if the operating system is 64 then the public directory would be C:/wamp64/www. Create a new folder called web1 under the www directory.
Step - 2
The opening script tag for PHP is
The closing script tag for PHP is
So the fundamental script to display "Hello World" is below
echo 'Hello World! This is my first PHP Script!';
For PHP scripting you can use any text editors like SubLime, NetBeans for PHP or PHPStorm. But in this tutorial, I will show you using basic notepad because that is very easy for begginers. Now open a new notepad from start menu of windows or press Win+R and type notepad click "OK". Just copy the above code and paste in the notepad. Finally save the file into C:/wamp64/www/web1 and name it as index.php. Please note that the encoding must be UTF-8 as per the screenshot below.
Step - 3
The final step of our tutorial is to execute the PHP script that we have saved already under C:/wamp64/www/web1/index.php. As we already started the wamp server, just open any browser and type http://localhost/web1/index.php hit enter!.
Here you go! you could able to see the message Hello World! This is my first PHP Script!
Please find below for screenshot of the output
We will see the basic variables, Input and Output scripting in the next part of this tutorial with experiments.
More articles: How to