Getting Started With PHP Part-1

February 03, 2012 // In: PHP
This tutorial is very basic level, If you are interested in web development and want to develop website in PHP and don’t know how to start learning php. Don’t worry I’m going to post a series of tutorials on PHP.
Lets start..
PHP is basically web programming language (Scriptiong Language) to develop interactive, and dynamic websites.  Its server-side scripting and its execution is performed at server. As its Server-Side Language, it needs a Web Server (Apache, IIS etc) to execute its code.
PHP supports almost all platforms (like Windows, Linux, Mac etc)
PHP is used as programming language, to store data we use DBMS and we store data in databases. MySQL is most commonly used as DBMS with PHP.
We also need a web server to execute PHP code. We commonly use Apache Server.
There are two ways to Install PHP, MySql and Apache Server

  1. Download PHP, MySql and Apache Server and Install all three separately and configure
  2. Download and Install Package (like Wamp, Xampp) ( No configuration required)

I Suggest you second method. Download and Install Package. You can download and install one of them.

  1. Download Wamp
  2. Download Xampp

Note: You can watch the tutorials How to Install Wamp or Xampp on youtube. There is a lot of tutorials on this topic.

By Default it will create a folder with the name wamp/xampp in your C drive or in the drive in which OS is installed.
OS drive -> wamp/xampp->www  ( C:/wamp/www)
In this tutorial I’m going to use WAMP server. After Installing wamp server, start wamp server by double clicking on wamp server’s icon.

Wamp server icon will be displayed on the Notification area of taskbar. After a few seconds, icon will turn to green. ( If you have skype installed in your system then port conflict may occur. To solve this problem read my post Resolve skype and wamp/apache server conflict )
Now, open your web browser and type localhostin the address bar and press enter..

Note: If you configure your server for different port other than 80 then you have to use port also. Say localhost:8080..
Now go to the root directory where you’ll create your projects..

It can be access directly through wamp server’s icons from notification area. You just need to click on icon and then click on www directory. The other way is just go to the drive where you install your wamp server (by default its C drive) and then go to wamp, and www folder. www is the root directory. You can create your files and folders for your projects here..
Lets create a folder with the name myproject.

Now we’ll create our first Hello world php file. To do this, open notepad and write the following code.


echo “Asalam-0-Alykum, Its Working”;
?>

and save this file with the name test.php in myproject folder which we have created earlier.
We write PHP code within. Short open tags ( ) can also be used. We can write PHP code anywhere in the page. echo is used to print something on the page.
You cannot open a php page directly from the browser, you can open the page only through your localhost.
i.e localhost/folder/file
Now to open this test page, write localhost/myproject/test.php in the address bar of your browser and press enter.

Hope you learnt something from this tutorial. I’ll post part 2 of this tutorial soon..

Simple PHP/MySql Pagination
Object-Oriented PHP for Beginners