A Comparison Study of Web Based Application Development Using PHP and ASP.NET

Morris M. Liaw, Ph. D. Abdul Mansoor Mohammed. Univ. of Houston Clear Lake Univ. of Houston Clear Lake Houston, TX 77058, US Houston, TX 77058, US [email protected] [email protected]

Abstract: developers of ASP.NET and PHP assure their users that both platforms are capable of This paper takes a detailed look at PHP, an fulfilling their web application needs, open source -side scripting language, ASP.NET requires the support of a much and compares it to its heavily marketed larger development community. Why this is counterpart ASP.NET. It explores various the case is worth investigating since both concepts which are pertinent to choosing languages have been utilized in creating programming platforms and outlines the very large and very successful web advantages of each language over the other. applications. A sample application called “Personal Media Center” is developed in PHP to 2. Brief Review of PHP: illustrate these concepts and advantages, and a summary of the factors which affect the As mentioned earlier, PHP is primarily usability of both platforms is discussed at focused on server-side scripting capabilities the conclusion of this paper. to provide with the necessary tools for creating web applications that are

heavily dynamic in nature. It is capable of performing all the actions of any CGI Keywords: PHP, MySQL, Web Application program and has a vast array of Platform, ASP.NET functionalities, e.g. collecting data,

Acknowledgement: generating dynamic web pages, and setting and accessing cookies for session control. Very special thanks to Matthew E. The primary functionalities of PHP, as Liaw (gordongartrell@.com), Stanford stated by its developers, are server-side University for proof reading the content of scripting, command line scripting, and this paper. desktop applications. It can be used on all major operating systems, including UNIX 1. Introduction: and Linux, and thus, gives web developers a

When developing a web application that has choice of and server-side scripting capabilities, the natural when deploying an application. Another choice for a today would be strong and significant feature of PHP is its one of the two most widely used scripting ability to support various databases. A languages, namely `s ASP.NET database enabled can be written and/or open source PHP. Though the with incredible simplicity using either

1 database specific extensions for MySQL or The following section discusses the abstraction layers like PDO [PHP Database application in more detail. Objects]. 3. About Personal Media Center: Based on a 2007 Netcraft survey, 54.9% [112,945,968] of 205,714,253 were The proposed functionalities of Personal hosted on Apache HTTP Servers whereas Media Center are those of a 25.9% [53,217,620] were hosted on designed primarily to host different types of Windows Servers. This information appears media such as pictures, music, and videos to indicate that PHP is a far more popular which can be remotely uploaded by the platform than ASP.NET for web-application website’s administrator. Subscribers and developers. Figure 1 shows the statistics for visitors from all over the world will able to [1] view this media, and registered users will be this survey. able to discuss and post comments about the Since we will be looking at PHP from the media in a manner akin to other social perspective of an entry level programmer, networking websites. Users will also be able we will only establish and verify its basic to register for updates and newsletters sent functionalities. We do this by developing a out by the administrator. simple 3-tier website called Personal Media Center.

2 The performance of PHP is put to the test by The application uses the cookie functions in using it to dynamically manipulate the entire PHP API to execute these authentication webpage`s text into either Simplified mechanisms. There is a single interface for Chinese or English based on the user`s all users, but the rights are based on the choice of language. user’s login credentials. This fully functional application is deployed on the DCM The application is designed with PHP (Division of Computing and Mathematics) technology to run on a web server running server at the University of Houston-Clear Apache Tomcat 6.0 and extensively uses Lake and can be tested at the following link. MySQL 5.5 for all database-related operations. Although any viewer with an http://sceweb.sce.uhcl.edu/liaw/mediacenterv2.0/ connection has the ability to browse The following figures show screenshots of content on the website, only the pages on the Personal Media Center administrator has the right to upload media application website. Figure 2(a) shows the to it. Additionally, only registered users will home page of the application, and Figure 2(b) be able to comment on the media. shows the gallery page of the website which serves as the root page for browsing all media.

3 For the Personal Media Center application, 4. Using PHP for Applications: there are three types of users as mentioned below. Each class of user has a different One of the biggest advantages of using PHP level of access, with the administrator when creating web applications is that PHP having the highest level and casual users scripts can be embedded directly into HTML having the lowest level of access control pages. During the initial development phase rights. of the Personal Media Center application, a static HTML website was designed using 1. Administrator common HTML and various text editors. 2. Registered users PHP scripts and actions were embedded into 3. Casual viewers the HTML pages later on which helped to simplify the development process by Figure 3 below is a simple flow chart of separating interface development from actions for the administrator of the functional implementation. application. Some of the additional functions not mentioned in the above chart can be found in the application but have been omitted for the sake of brevity.

4 The major components of functionality from Each function call follows the sequence of an administrator’s perspective are uploading actions below: and managing media. The following snippets of code in Figures 4(a) and 4(b) 1. Check the user-set cookie for show the PHP functions used to upload and language preference; if none is delete files, respectively. found, set the cookie to English move_uploaded_file takes the path of the file as the default preference. 2. Look up the phrase in the to be uploaded and the future path of the file dictionary of defined phrases. at the server as arguments and moves the file 3. Return the phrase in the to the server, thus completing the upload. corresponding language found in unlink [2] takes the path of the file and the cookie. simply deletes it from the server. Currently, this may not be the best As mentioned previously, a translation implementation of a translation function as function built into the application can be one must specify each and every phrase in used to test the performance of PHP. The the dictionary. However, the translation function is able to translate the text within function plays a key role in testing PHP’s Personal Media Center by using a static ability to handle large numbers of function dictionary of user-defined terminology. calls from a specific request. A snippet from the translation dictionary is The translation function is called for each shown in Figure 5(a). and every text phrase in all of the pages of the website.

5 5. Using MySQL: 6. Conclusion:

All database-related back-end operations for The development of Personal Media Center Personal Media Center were done using shows that PHP has several advantages over MySQL. An important reason for choosing Microsoft’s ASP.NET. The following MySQL as a database back-end was PHP’s crucial factors were analyzed to reach this built-in support for it. The MySQL query conclusion- generator in PHP is very useful in the formulation and testing of queries. (i) Cost: When compared to ASP.NET, PHP leads in this area because it is The functions open and close are not free, and no additional licensing fee required for opening and closing is required to use it. Each member of connections to MySQL servers. A the PHP suite, known collectively as connection initialization, query declaration, LAMP (Linux, Apache, MySQL, and execution request is shown in the and PHP), is also free, with support snippet of code in Figure 6(a). and upgrades provided at no extra cost. On the other hand, licensing The result set of a select query is stored in Microsoft’s server can cost the requesting variable and can be accessed over $1000. This makes LAMP a as shown in Figure 6(b). very popular platform for designing inexpensive yet effective [3] applications.

6 (ii) Performance: When the performance 7. References: of the programming language is considered alone irrespective of [1] : www..net database engine used, PHP has an advantage over ASP.NET because it [2] Murach, Joel, and Ray Harris. Murach's is known for running “lightly” on PHP and MySQL: Training & Reference. [Fresno, servers and is free of any unneeded Calif.]: Mike Murach & Associates, 2010. Print. packages. The lack of GUI’s also gives PHP servers an extra edge in [3] Kohan, Bernard. "PHP vs ASP.net performance. Comparison." PHP vs ASP.net Performance Comparison. Bernard Kohan. Web. 20 Mar. (iii)Complexity: Tasks can be 2012. . code in PHP than in ASP.NET. Though coding outside of HTML [4] Web Resource For Zend: pages may initially appear to [http://www.zend.com/en/] simplify the development process, having to map related code between separate files when using ASP.NET requires a high level of understanding which can act as an obstacle to more novice programmers. It is no mystery then why PHP has become very popular with beginners.

Future studies will explore why the .NET framework is still popular with many developers, despite several advantages associated with PHP and the LAMP software suite.

7