PHP Introduction

If you want to build a dynamic website, or a shopping cart, or may be your own blog system, then you’ve got to learn a specific server side programming  language and in my personal opinion, PHP would be the best choice.

So, what is PHP?

To your answer….

PHP is a server side scripting and a general purpose programming language mainly used for building dynamic websites, web applications and web based software. PHP is a recursive acronym which stands for ‘Hypertext Preprocessor’. It was developed back in the year 1994 by a Danish-Canadian programmer named Rasmus Lerdorf. Initially, when it was released, PHP stand for ‘Personal Home Page’.

A PHP script can be embedded anywhere inside html and xml and even JavaScript and its code is processed only on a web server by a PHP interpreter. This is to be noted that PHP is not a compiled language, rather it is an interpreted language, that means in its execution interpreter is involved, not a compiler.

A server side processing or activity involves a web browser (often called as end user or client) sending HTTP requests to a web server. The server then processes the requests and then give response to the browser in the form of code, which is then turned into content by the browser and displayed on the user’s screen. As of now it is the most popular server side scripting language for web development (or more specifically, for the back end design of websites).

A website is a collection of different web pages. A web page is simply a document that can be open on a web browser and the code of a web page can be a mixture of various things like HTML, CSS, JavaScript, PHP. If there is PHP in the web page, then it would the very first thing that is processed. Therefore it is called “Hypertext Pre-processor”.

if you want to know more about the structure of a website or what a website is, visit this link What is a website

Why you should use PHP –

  • It is fast as compared to other server side scripting languages.
  • The learning curve is simpler as compared to other server side scripting languages.
  • It is the most popular language in web development.
  • Most of the web servers now a days supports PHP because of its popularity.

Features of PHP –

  • It is a simple to use and easy to learn language as compared to other server side scripting languages and technologies like ASP.NET, Ruby, Perl. Moreover PHP is faster as compared to these languages.
  • PHP supports multiple programming paradigms including procedural, object-oriented, imperative, reflective and functional programming.
  • It is an open source language, it can be downloaded free of cost over the internet.
  • PHP can receive data from html forms, communicate with databases. create sessions, create, send and receive cookies, send emails using SMTP (Simple Mail Transfer Protocol). It can works with a number of DBMS (Database Management Systems) like MySQL, PostgreSQL, Oracle, Sybase and many more.
  • The syntax of PHP is identical to C programming language.
  • The files of PHP must have the extension “.php”. There were some older extensions as well like .php3, .php4, .php5 and .phps, however as of now only .php is used.
  • It is a platform independent language. This means that a PHP code can be run on every operating system like windows, Linux, MAC.
  • A typical PHP file can have html, CSS, JavaScript within.
  • PHP is a loosely typed language. What it means that you need not to declare a variable of a particular datatype before using it. Variables are assigned a particular data type based on the value they store.
  • For building complex and larger application with ease, there are a number of MVC (Model, View, Controller) frameworks like CodeIgniter, Laravel, CakePHP, Symfony, Yii are available that are written in PHP.
  • It is a flexible language. It can be integrated with html, xml, JavaScript and many more languages.
  • The PHP interpreter executes the PHP code written inside its delimiters only. A PHP script starts with <?php and ends with ?> (<?php & ?> are called delimiters) . However there is a also a shortened form <? to open a PHP script which is sometimes used by professional PHP programmers and developers.
  • A piece of PHP code can create, read, write and close files, can communicate to databases and even remote servers.

Syntax of PHP –

Here is a simple example that would print the message “Hello World”-

     echo "Hello World";//this line would print the message hello world.

The line after // is a comment. A comment is an integral part of a programming or a scripting language. A comment is ignored by the compiler or the interpreter and would not be executed. Comments are used for documentation instead. That means they are added in the code to make the code more easier to read and understand.

In PHP comments are written as single line or multiline comments. Above example shows a single line comment. Below given example shows a multiline comment.

    This is comment one
    echo "Hello World";
    This is comment two

In the above example no message would print because it is written inside comment section. As you can see, in PHP multiline comments starts with /* and ends with */.

Interesting facts about PHP

  • WordPress which is the most popular blogging system is powered by PHP.
  • More than 200 Million websites including some the most popular websites in the world have been developed using PHP.
  • There are approximately five million PHP developers worldwide.
  • Rasmus Lerdorf(The creator of PHP ) had no intensions to make PHP a programming language. He had created the language only to manage his personal web pages.
  • Some of the most popular websites like Flickr, Facebook, TED are powered by PHP.
  • The maximum execution time for a PHP script to execute is 30 seconds by default. If the time exceeds this limit, PHP generates an error.
  • Any one who can program in PHP can contribute to PHP language. Here is the link –
  • The mascot of PHP is a blue elephant.
  • The creator of PHP originally developed the language to replace a bunch of Perl Scripts in his ‘Personal Home Pages’.
  • PHP can be used on almost every operating system including all major operating operating systems like Windows, Linux and MAC OS.
  • It was initially written as a set of Common Gateway Interface in C.

Leave a Comment

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