This tutorial will teach you how to use PHP (PHP: Hypertext Preprocessor) to help creating dynamic and more user interactive websites.

Before learning PHP it is important to be familiar with the HTML and CSS already, as well as JavaScript language.

History of PHP

Here is brief history of PHP language:

  • Hypertext Preprocessor commonly known as PHP is extensively used open source scripting language which is executed on a server. PHP is specially used for the web development and free to download.
  • PHP is a server side scripting language and runs on various platforms such as Windows, Linux, etc... It is compatible with all the major servers (Apache, IIS). PHP can access all kinds of databases, collects information from tables, alters the database and fetches the contents of the database table.
  • PHP is capable of generating dynamic page contents, send and receive cookies and encrypt data.
  • PHP started as a home project by Rasmus Lerdorf, who wrote Common Gateway Interface (CGI) in 1994. At that time it has the ability to work with forms and to communicate with the database. In 1995, Lerdorf decided to public PHP (Personal Home Page) Tools version 1.0 in order to identify bugs and improve the codes. It embedded HTML and the syntax resembled with Perl in a simpler manner.
  • PHP version 2.0 released in 1997 after a long beta testing. Later, Zeev Suraski and Andi Gutmans started working on PHP and rewrote the parser and released PHP 3 in 1998.
  • PHP 4 was introduced in year 2000 by Zend Engine and finally PHP 5 in year 2004 was released by new Zend Engine II. It includes new features such as object-oriented programming, Data Object (PDO) extension and huge performance enhancement.

PHP can easily embed with HTML:

PHP basic code sample

Fig. 1 Example of PHP embedded in HTML

PHP code embedded in HTML in Fig. 1 in which instead of lengthy commands like in C or Perl, it only uses one sentence and prints “Hello World”.  In the above example, the PHP code starts with <?php” and ends with “?> which allows the browser to jump into PHP mode and out of it. Anything in between start and end is considered a PHP script and referred to its libraries. 

Since HTML and JavaScript are on the front end, while PHP runs on the back end (server), both HTML and JavaScript redirect the web page to the PHP through server. The server scans for the “.php” extension files, as it finds the specified file, it reads through and distinguishes each line before it acknowledges and brings its content to the web browser.


Each chapter has attached an interactive example that can be easily modified and tested as wanted.

All examples can be found at the end of the tutorial.

›› go to examples ››


At the end of the tutorial you will find a complete reference list with data types, operators, statements, functions, etc...

›› go to references ››