Friday, October 15, 2010

PHP Strengths and Weaknesses


For a web site to be competitive today, it must be interactive, dynamic, and capable of performing on-line transactions. Gone are the days, when entire web sites were created using static pages. Today, web developers are using tools and programming languages to help them create customized web pages, develop shopping cart applications, and track user's behaviors. To meet these development challenges, this paper will examine the strengths and weakness of one of the latest programming languages used to create dynamic web pages known as 'PHP Hypertext Preprocessor' (PHP). This software, originally known as Personal Home Pages, was developed in 1997 and is currently being used in over 10 million domains.

Before PHP, developers used CGI (Common Gateway Interface) scripts for interacting with users, querying databases, etc. However, since CGI applications are separate, stand alone programs, scalability is missing because multiple CGI applications running concurrently can quickly consume all available memory. To avoid this problem, PHP was developed using a three tier architecture. The first tier is the client also known as the browser. The second tier is the server (including both the web server and PHP interpreter). The third tier is the database system. Using this approach, it avoids the forking of external programs found in CGI applications which can quickly consume all available memory.
With PHP you write HTML script with embedded code delineated with special start and end tags. The embedded code is executed on the server and then sent to your browser. What is displayed in the browser is the result from the code's execution. This is very different from other scripting languages like Perl and C where code is written to output HTML commands. While similar to JavaScript, the main difference with PHP is the code is executed on the servers, whereas with JavaScript the code is executed on the client-side. With JavaScript it is possible to determine the underlying code, whereas with PHP the underlying code is hidden from the user.
Some of the strengths of PHP include:
Supports database connectivity. PHP can access over 20 different databases including MySql, Oracle, and MS Access.
Supports sessions. PHP can generate unique session IDs. The ID follows the user during a single session on a web site. This simplifies creating shopping cart applications and tracking user's behaviors.
Eliminates client configuration problems. With PHP there is no need to worry if the client has the appropriate software installed, since the application is executed on the server.
Reduces development time. Even a newcomer can begin developing PHP applications in hours. Yet PHP contains many advanced features for professional programmers.
Maintains source code security. The user does not see your source code as they do with JavaScript.
Some of the weaknesses of PHP include:
Client side scripting. Since PHP is a server side language, the programs cannot be executed on the client. Thus the server might be slowed down while multiple PHP applications are executed.
Error Handling. Error handling in PHP is still primitive. However you can code your way around most problems.
The diagram below shows how the browser, web server, and database interact via the Internet. In step 1 the browser makes a request to the server. The embedded PHP code within the HTML document is executed in step 2. If a database is queried then steps 3 and 4 are taken. The results are then returned to the PHP program. In step 5 the results are returned to the server. Finally in step 6 the information is displayed in the browser.
Client side scripting. Since PHP is a server side language, the programs cannot be executed on the client. Thus the server might be slowed down while multiple PHP applications are executed.
Error Handling. Error handling in PHP is still primitive. However you can code your way around most problems.
The diagram below shows how the browser, web server, and database interact via the Internet. In step 1 the browser makes a request to the server. The embedded PHP code within the HTML document is executed in step 2. If a database is queried then steps 3 and 4 are taken. The results are then returned to the PHP program. In step 5 the results are returned to the server. Finally in step 6 the information is displayed in the browser.

No comments:

Post a Comment