Setting up The Environment:
First, we have to set up our environment in our machine for PHP development.
We can either use Apache server or Nginx server to run PHP script but to make thing easier I would suggest to use XAMPP.
Once you have it installed, go to C:/xampp or if you choose to install in different directory, find the xampp folder in the directory that you have chosen before.
Find the xampp_start.exe and start it. This will start both the Apache server and MySQL with you can access through phpmyadmin.
Writing your first php program:
Before writing your first program in Php, It is required to know that where you have to write the program. For xampp the directory to write php files is the htdocs/ in the xampp folder.
Here you can create any type of php program you want.
For writing you first program in php you definitely required a text editor, It could be either simple notepad, notepad++ or sublime, For most of the web developers the popular one’s are sublime and atom
Open any text editor here and write the following code in it:
echo “This is my first php program”;
And save it with .php extension like firstprogram.php
Running your php program:
Open any web Brower and type localhost/yourprogramname.php. In the following example we need to write the following line in url to run our program:
It will display a page with a message :
This is my first php program
Congratulations, You have just created a php program. Now go to your file in the htdocs/ and start editing it and make something beautiful.