Breaking News
You are here: Home / Notes / SEM-5 / PHP MYSQL / Introduction to PHP

Introduction to PHP


  • PHP was written in the C programming language by Rasmus Lerdorf in 1994 for use in monitoring his online resume and related personal information. For this reason, PHP originally stood for “Personal Home Page”.
  • Two programmers, Zeev Suraski and Andi Gutmans, rebuilt PHP’s core, releasing the updated result as PHP/FI 2 in 1997. (Name changed to PHP: HyperText Preprocessor ).
  • In 1998, PHP 3 was released, which was the first widely used version.
  • PHP 4 was released in May 2000, with a new core, known as the Zend Engine 1.0.
  • PHP 5 was released in July 2004, with the updated Zend Engine 2.0. Among the many new features in PHP 5 are:

1.      improved object-oriented programming

2.      embedded SQLite

3.      support for new MySQL features

4.      Exception handling using a try..catch structure

5.      the Filter library (in PHP 5.1)

6.      better XML tools

7.      PHP 6 has been developed in October of 2006.


What is PHP?

  • PHP is a server-side scripting language.
  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a server-side scripting language, like ASP,JSP means it executed on server.
  • PHP is an open source language
  • PHP runs on different platforms (Windows, Linux, Unix, etc.)
  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
  • Powerful, Robust, scalable.



  • PHP stands for Hypertext Preprocessor“.  It is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Open source

  • It is an interpreted language.
  • There are three main fields where PHP scripts are used.

1.      Server side scripting

2.      Command line scripting.

3.      Writing client-side GUI applications. For this PHP-GTK is used.

—  PHP-GTK is an extension for the PHP programming language that implements language bindings for GTK+. It provides an object-oriented interface to GTK+ classes and functions and greatly simplifies writing client-side cross-platform GUI applications.

  • PHP can be used on all major operating systems, including Linux, many Unix variants, Microsoft Windows, Mac OS X etc.
  • PHP has also support for most of the web servers today. This includes Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet servers, Oreilly Website Pro server and many others.
  • You also have the choice of using procedural programming or object oriented programming, or a mixture of them.
  • PHP does more than just generating dynamic web-pages.
  • PHP’s abilities includes:

1.      Generating images dynamically

2.      PDF files

3.      Flash movies

4.      Compression

5.      Download and upload

6.      XML support

  • PHP also has support for talking to other services using protocols such as LDAP (Light-Weight Directory Access), IMAP(Internet Message Access Protocol), SNMP(Simple Network Management Protocol), NNTP(Network News Transfer Protocol), POP3, HTTP, COM (on Windows) and countless others.
  • You can also open raw network sockets and interact using any other protocol.
  • PHP has support for the WDDX(Web Distributed Data eXchange) complex data exchange between virtually all Web programming languages. (Support for web services)
  • PHP has support for instantiation of Java objects and using them transparently as PHP objects. You can also use CORBA extension to access remote objects.

e.g. You can use java classes in php.



  • Web servers are computers that deliver (serves up) Web pages.
  • Every computer on the Internet that contains a Web site must have a Web server program.
  • Two leading Web servers are Apache, the most widely-installed Web server, and Microsoft’s Internet Information Server (IIS).




  • is a powerful, flexible, HTTP/1.1 compliant web server
  • implements the latest protocols, including HTTP/1.1
  • is highly configurable and extensible with third-party modules
  • can be customized by writing ‘modules’ using the Apache module API
  • provides full source code and comes with an unrestrictive license



  • Zend
  • Joomla
  • CodeIgniter
  • CakePHP
  • QPHP
  • Zoop
  • Prado
  • PHPDevShell
  • Drupal
  • Quick PHP
  • Solar
  • Yii
  • Zext
  • DooPHP
  • Smarty


PHP  Instructions

  1. File extension Should be .php
  2. Index.php file is executed first
  3. You Require a Wamp Server to run php File
  4. All the PHP Files Should be in the WWW directory of wampserver
  5. Goto Local Host then Find your Application and Run it

PHP Syntax

PHP Tags

PHP code must be contained in special tags so that the PHP interpreter can identify it. Depending on the PHP configuration, these tags can take several forms:

<?phpPHP CODE GOES IN HERE?> This is the most commonly used (and recommended) form. It is known as the XML style, because it can be used inside of an XML document without causing the document to become poorly formed.
<script language=”php”>PHP CODE GOES IN HERE</script> HTML or Script style tags.
<?PHP CODE GOES HERE?> “Short” tags.
<%PHP CODE GOES HERE%> ASP-style tags.

In this manual, we will use the first form shown as it is the most common and the most portable.


  1. Variables are used for storing a values, like text strings, numbers or arrays.
  2. When a variable is declared, it can be used over and over again in your script.
  3. All variables in PHP start with a $ sign symbol.
  4. And echo is used for Printing.



echo $temp; // outputs "10"


Naming Rules for Variables

  1. A variable name must start with a letter or an underscore “_”
  2. A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )
  3. A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_string), or with capitalization ($myString)


How PHP Is Parsed?

  1. The Web browser requests a document with a .php extension to the web-server.
  2. After receiving the request Web server sends the request on to the PHP parser.
  3. The PHP parser finds the requested file and scans it for PHP code.
  4. When the PHP parser finds PHP code, it executes that code and places the resulting output (if any) into the place in the file formerly occupied by the code.
  5. This new output file is sent back to the Web server.
  6. Webserver converts it in to HTML and send it to Web Browser as a response.
  7. The Web browser displays the output.

Because the PHP code is parsed by the server, this method of code execution is called server-side. When code is executed by the browser, such as JavaScript, it is called client-side.


How  PHP Works?

When a user navigates in her browser to a page that ends with a .php extension, the request is sent to a web server, which directs the request to the PHP interpreter.

working of php

As shown in the diagram above, the PHP interpreter processes the page, communicating with file systems, databases, and email servers as necessary, and then delivers a web page to the web server to return to the browser.


Comments in PHP

// single line comment


Multi line comments


// echo “Hello India”




   echo $a+$b;




Download Paper Solutions from Below Link

About admin

Scroll To Top