Please login to post comment

Introduction to PHP

  • Swetha Y
  • Jun 25, 2019
  • 0 comment(s)


Introduction to PHP:


PHP was first conceived in the year 1994 and was originally the work of Rasmus Lerdorf. PHP originally stands for Personal Home Page, but it was changed with GNU(Gnu`s Not Linux) recursive naming conventions and now it stands for Hypertext Pre-processor.

PHP is one of the most popular server-side scripting languages which are widely used for creating websites. As of 2019, PHP is used in 244 million sites worldwide, and this number is growing rapidly. (To know the current number visit-

PHP is a server-side programming language which means that it runs on your web server software, which is going to serve HTML to clients (browser).

The current Major Version is 7.1.30. PHP is an open source product. Anyone can access the source code. You can use it, alter it, and redistribute it all without any charge.

PHP code can be easily embedded in HTML files. PHP codes are executed on the server whereas HTML codes are directly rendered on the browser. PHP documents consists of file extensions like .php, .php3, and .phtml. When a web server encounters this extension in a requested file, it automatically passes it to the PHP processor.


Improvements in PHP 7 / Differences betweeb php 7 & 5.


Performance and Speed :

The PHP-7 code base is optimized in order to reduce memory consumption and increase speed and performance. Benchmarks for PHP consistently show speeds twice as PHP 5.6 and many times faster.

PHP 7 uses a brand new model of engine called PHP-NG(PHP Next Gen) authored by Xinchen Hui, Nikita Popov. This new PHPNG engine improves performance as much as twice with optimized memory usage.



Type Declarations



In earlier PHP versions, the programmer cannot define the return type of a function or method. This has been a huge drawback in the real-life coding scenario as the programmers were unable to prevent unwanted return types and generate exceptions. PHP 7 allows programmers to declare the return type of the functions as per the expected return value. This is certainly going to make the code robust and accurate.


There are four different return types available bool, int, string, and float.


Error Handling and 64-bit Support :

It is not easy to handle fatal errors in PHP 5. PHP 7 has eased the process as it has replaced several major errors with exceptions that can be handled effortlessly. This has been achieved with the introduction of the new Engine Exception objects.

PHP 7 has 64-bit support due to which you will be able to use native 64-bit integers as well as large files and hence, you can run applications flawlessly on 64-bit system architectures whereas this feature is not present in PHP 5.



Anonymous Class

One of the major Improvements to PHP 7 that is not present in earlier versions is the anonymous class. Even though PHP had an object-oriented approach from PHP 5, it lacked this feature. An anonymous class is used to speed up the execution time. It is suitable when you do not need to execute a class more than once and you do not need to document it in the project document.


New Operators :

New operator introduced is called a spaceship operator that comes with the notation <=>. It can be mostly used in sorting and combined comparison.

It works the same as strcmp() and it is considered to be a replacement for the library function version_compare().

It returns 0 when the operands are equal and 1 when the left side is greater than the right and -1 in case of the opposite


Why PHP is used in web development?        

There are many reasons to use PHP in Web Development and few are listed as below.


1. Open Source, Simple, and Easy:

PHP is a free language with no licensing fees. It developed and updated by the developer community worldwide. PHP is one of the popular(easiest) language for building websites as its syntax is very similar to C and JAVA. If the developer is good in C and JAVA, they can learn PHP scripting language and it is a good alternative to the competitors such as Java and JSP

2. Compatibility:

PHP runs seamlessly with the major operating system such as Windows, Mac, Linux, Solaris, RISC OS etc. PHP is ideal for cross-platform development. Programmers also have an option for choosing any databases like MySQL, Oracle, Sybase, etc. PHP is compatible with all kind of servers which are used in the present generation servers like Apache, IIS, etc. PHP supports some of the commonly used protocols like HTTP, POP3, LDAP COM, etc.


3. Flexible and Scalable:

PHP is one of the most flexible server-side languages. It allows programmers for making changes to the code during different stages of development. Developers can easily add new features or functionality to the website even after writing the code. Changes can also be done in existing code and can also be modified to add new features to the website without requiring a server reboot.

PHP is being used by the largest and most powerful social media platform Facebook. On March 20-2014, Facebook has even created a language named "Hack" for the hip-hop Virtual Machine (HHVM) as a dialect of PHP. This shows the level of flexibility, robustness, and scalability that is built into PHP.


4. Object-Oriented Language:

PHP supports object-oriented programming approach. PHP provides all the advantages of oop from reducing the line of codes to the reuse of classes. Maintenance and debugging of the program made easy and fast. Developers can reuse defined variables and functions and call it anytime within the program


5. Built-in functions:

PHP has many built-in functions, which helps in carrying out various useful tasks. PHP permits you to send an email, connect to other network services, generate GIF images, and also generate PDF documents, all with just a few code steps.


6. Secured:

PHP is one of the most secure ways of developing websites and dynamic web applications. PHP has multiple layers of security to prevent threats and malicious attacks. It is the major importance of using PHP to develop a hybrid web application.


7. Frameworks:

The PHP community is continuously involved in developing frameworks, extensions to meet the emerging requirements of the businesses. As a result of this, a number of PHP frameworks are created. Using frameworks, Developers can develop and add newer functionalities and features to their website with ease. The popular frameworks that are made on PHP are CodeIgniter, Symfony, Laravel, Zend, and yii.



The Request/Response Procedure


Steps involved during the dynamic client/server request/response sequence:

1) The user enters into your browser’s address bar.

2) Browser consults an additional Internet service called the Domain Name Service (DNS) to find its associated IP address of the server.

3) Browser issues a request to that address for the web server’s home page.

         4) The request crosses the Internet and arrives at the web server.

         5) Web server received the request, fetches the home page from its hard disk.

        6) a) Web server notices that it is a file incorporating PHP scripting and passes the page to the PHP processor.PHP interpreter executes the PHP code.


         b) Some of the PHP contains MySQL statements, which the PHP interpreter now passes to the MySQL database engine.


       7) The PHP interpreter returns the results of the executed PHP code, along with the results from the MySQL database, to the web server. The web server returns the page to the requesting client, which displays it.







Please login to post comment

( 0 ) comment(s)