An introduction to PHP

learn php web development

Learn php web development


Today, In this tutorial I’ll cover the basics of php web development.

An introduction to php:-

PHP stands for Hypertext preprocessor. PHP is a server-side programming language. It is widely used language for server-side programming. There are many big companies that are using php for web development, for instance whole is written in php as well as most used blogging platform wordpress also using php.  PHP is very easy language.


First of all to Learn php web development, you’ll be needed to do environment setup on your local machine because php is not client side it’s server-side.

Environment setup:-


If you are a windows/mac user, I would recommend you to install xampp(includes Apache httpd web-server, MySQL, PHP, Perl) on your machine.

Follow below steps to install php parser on Linux/Unix

Step1:- Download latest php distribution from here.

Step2:- Download latest Apache source distribution from here.

Step3:- Download GNU make utility from here.

Step4:- Now lets install php and apache. First unzip and untar Apache distribution by running

gunzip -c apache_1.3.x.tar.gz
tar -xvf apache_1.3.x.tar

Step5:- Build apache server by running

cd apache_1.3.x
./configure --prefix=/usr/local/apache --enable-so
make install

Step6:- Now, unzip and untar php

gunzip -c php-5.x.tar.gz
tar -xvf php-5.x.tar
cd php-5.x

Step7:- Build php with mysql by running

./configure --with-apxs=/usr/sbin/apxs \
make install

Step8:- Install the php.ini file. Edit this file to get configuration directives:

cd ../../php-5.x
cp php.ini-dist /usr/local/lib/php.ini

Step9:- Tell your Apache server where you want to serve files from, and what extension(s) you want to identify PHP files. .php is the standard, but you can use .html, .phtml, or whatever you want. Go to your HTTP configuration files (/usr/local/apache/conf or whatever your path is. Open httpd.conf with a text editor. Add this line

AddType application/x-httpd-php .php

Now, restart your apache server.

Now, run chmod 755 /home/httpd/html/php.

Step10:- Open any web browser and in url type http://localhost:80/ or . You can ignore :80.


So lets get started to learn php web development

Now we’ll create a new file called index.php in htdocs directory. Add this line in it <?php phpinfo(); ?>.

Now open web browser and enter url http://localhost/index.php .

PHP can be embedded in html as <h1><?php echo "hii"; ?></h1>. It will produce hii.

What are <?php and ?>

These are the php starting and end tags. They differentiate php from other elements.

Comments in php

php supports both single line and multi line comments. For example

// single line comment nbsp;/*
This is multi line comment

Writing something as output and returning output

<?php echo "hello"; ?> it will write hello as output.

<?php return "hii"; ?> it will not write output it will only return.

Variables in php

In php, variables are defined by adding $ in the front of variable name. You don’t need to add var before variable.

<?php $var = "hell"; $var1 = 1; echo $var; echo $var1+2; ?> In this program there are two variables, $var and $var1. PHP variables are perl-like.

PHP has a total of eight data types which we use to construct our variables:
 Integers: are whole numbers, without a decimal point, like 4195.
 Doubles: are floating-point numbers, like 3.14159 or 49.1.
 Booleans: have only two possible values either true or false.
 NULL: is a special type that only has one value: NULL.
 Strings: are sequences of characters, like ‘PHP supports string operations.’
 Arrays: are named and indexed collections of other values.
 Objects: are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class.
 Resources: are special variables that hold references to resources external to PHP (such as database connections).


What is ; in php

; in php is used after any statement or function.

Running php from Command Prompt

Create a file named test.php and add<?php echo "hello"; ?> line in it and run $ php test.php. It will produce hello and exit.

Creating functions in php

Syntax: function funcname(param1, param2 ... paramn){



Example:- <?php function add($n1, $n2){return $n1+$n2;}  echo add(5,6); ?>. It will print 11.

Decision making

If :-

Syntax: if(condition){statements;}


Syntax: if(condition){statements;}else{statements;}


In this way you have learned the basics of php web development. Keep visiting us for next tutorials. Thank you! Visit my other posts here.

3 replies
  1. pieczatki
    pieczatki says:

    Today, I went to the beachfront with my kids.
    I found a sea shell and gave it to my 4 year old daughter
    and said “You can hear the ocean if you put this to your ear.” She placed the shell
    to her ear and screamed. There was a hermit crab inside and it pinched her ear.

    She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!

  2. LarryItelm
    LarryItelm says:

    Всем привет! Класный у вас сайт!
    Что думаете по этим новостям?: 60 минут. Ток-шоу с Ольгой Скабеевой и Евгением Поповым, 07.04.17
    Ещё много интересного по теме нашел тут: новороссия лнр online

  3. RobertNoile
    RobertNoile says:

    Приветствую всех!
    Нашел познавательную информацию на этом сайте: : Кошка на охоте Современные апартаменты. Интересный дизайн


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *