Whole document tree
    

Whole document tree

PHP HOW-TO: Major Features of PHP Next Previous Contents

5. Major Features of PHP

  • Standard CGI, FastCGI and Apache module support - As a standard CGI program, PHP can be installed on any UNIX machine running any UNIX web server. With support for the new FastCGI standard, PHP can take advantage of the speed improvements gained through this mechanism. As an Apache module, PHP becomes an extremely powerful and lightning fast alternative to CGI programmimg.
  • Access Logging - With the access logging capabilities of PHP, users can maintain their own hit counting and logging. It does not use the system's central access log files in any way, and it provides real-time access monitoring. The Log Viewer Script provides a quick summary of the accesses to a set of pages owned by an individual user. In addition to that, the package can be configured to generate a footer on every page which shows access information. See the bottom of this page for an example of this.
  • Access Control - A built-in web-based configuration screen handles access control configuration. It is possible to create rules for all or some web pages owned by a certain person which place various restrictions on who can view these pages and how they will be viewed. Pages can be password protected, completely restricted, logging disabled and more based on the client's domain, browser, e-mail address or even the referring document.
  • PostgresSQL Support - Postgres is an advanced free RDBMS. PHP supports embedding PostgreSQL "SQL queries" directly in .html files.
  • RFC-1867 File Upload Support - File Upload is a new feature in Netscape 2.0. It lets users upload files to a web server. PHP provides the actual Mime decoding to make this work and also provides the additional framework to do something useful with the uploaded file once it has been received.
  • HTTP-based authentication control - PHP can be used to create customized HTTP-based authentication mechanisms for the Apache web server.
  • Variables, Arrays, Associative Arrays - PHP supports typed variables, arrays and even Perl-like associative arrays. These can all be passed from one web page to another using either GET or POST method forms.
  • Conditionals, While Loops - PHP supports a full-featured C-like scripting language. You can have if/then/elseif/else/endif conditions as well as while loops and switch/case statements to guide the logical flow of how the html page should be displayed.
  • Extended Regular Expressions - Regular expressions are heavily used for pattern matching, pattern substitutions and general string manipulation. PHP supports all common regular expression operations.
  • Raw HTTP Header Control - The ability to have web pages send customized raw HTTP headers based on some condition is essential for high-level web site design. A frequent use is to send a Location: URL header to redirect the calling client to some other URL. It can also be used to turn off cacheing or manipulate the last update header of pages.
  • On-the-fly GIF image creation - PHP has support for Thomas Boutell's GD image library which makes it possible to generate GIF images on the fly.
  • ISP "Safe Mode" support - PHP supports an unique "Safe Mode" which makes it safe to have multiple users run PHP scripts on the same server.
  • Many more new features are being added in newer releases of PHP. Visit the main web site at http://www.php.net
  • It's Free! - One final essential feature. The package is completely free. It is licensed under the GNU/GPL which allows you to use the software for any purpose, commercial or otherwise.

5.1 Advantages of PHP over Java

PHP is an established server-side scripting language for creating dynamic Web pages. As a language that has been designed expressly for the Web, it brings many features that commercial entities are looking for:

  • Exceptionally short learning curve
  • Quick development time
  • Very high performance

This is essential for companies who are faced with scarce skilled programming resources and ever-tighter time to market deadlines. In addition, PHP supports all major platforms (UNIX, Windows and even mainframes), and features native support for most popular databases. All these factors make it a very good choice for Web development: such shops working with PHP have reported being able to hire non-programmers and have them producing usable code within days. Programmers familiar with languages such as C, C++ or Java frequently find that they can begin programming in PHP within a few hours.

The fact that PHP was designed specifically for Web development gives it an edge as a development tool, as Intranet Design Magazine explains:

"PHP was built with the needs of Web developers in mind... Unlike other cumbersome, overhead-laden approaches, PHP is lightweight and focused on the Web - where it can solve complex problem scenarios quicker and more easily than comparable technologies."1

Java began its life as a programming language and was initially aimed at running client-side applications inside of Web browsers. Over the last few years, the problems associated with these "applets," as they were known, has led Sun and many other Java developers to use the language in other ways. One of the most prominent ways is in server-side programming, allowing Web sites to connect to databases and produce other server-side applications, or "servlets." Sun came out with Java Server Pages (JSP) as a means of writing servlets. JSP, like PHP, is highly portable across different platforms (even though PHP supports any 32-bit or better platform, whereas JSP supports only platforms that have a Java virtual machine available). However, a beginner with no programming background will find it exceptionally difficult to begin working with servlets,because of the complexity of the language as well as the complicated JSP system design.

JSP's performance also leaves much to be desired: a recent survey in ZDnet's eWeek online publication found that PHP is as much as 3.7 times faster than JSP. In the Web environment, this makes JSP a significantly worse solution - because it can perform less transactions per second, and features considerably slower response times.

ZDnet's eWeek also noted that

"JSP is a relatively new technology and still has clear market immaturities in terms of tools, support resources and available talent."...Because JSP is based on Java, a strongly typed language, we had to declare the types of variables we used and manually convert between types when necessary. This makes JSP the hardest of the scripting languages we tested for nonprogrammers to learn..."

PHP works with Java

It is important to note JSP is just one language with which Java objects can be accessed. PHP also can also integrate with Java, which means that it can be used as the scripting language for activating Java logic, just as much as JSP can. Unlike JSP, however, PHP also integrates with other component models, such as Microsoft's COM, and adding support for new object models is extremely easy. This means PHP's extensibility is infinite. JSP, on the other hand, is completely dependent on Java.

IBM programmer Sam Ruby uses PHP in combination with Java. Using the native Java support in PHP, Java objects can be created and used transparently, as if they were regular PHP objects.

AuctionWatch , which enables businesses of all sizes to benefit from dynamic pricing environments, has over 2.6 million unique visitors per month; 300K+ registered users; 1.2 million+ auctions launched every month. They tried to use Java, but opted for PHP because it's easier to use and much faster to develop with. For further information, please contact Ben Margolin, Director of Seller Services for AuctionWatch (ben@auctionwatch.com).

Programming consultant Reuven Lerner has made some comparisons among the languages. His view of PHP is summarized as follows:

"The language is easy to learn. Graphic artists and Web designers might claim that they are not programmers, but the fact is that they're doing increasingly large projects in JavaScript, VBScript, and other simple programming languages. PHP is much more regular and well-defined than Perl, and is much easier for new programmers to grasp than Java. Indeed, PHP seems like a server-side version of what JavaScript could have been, but isn't. Someone with little or no programming experience can learn PHP and work with it after a very short period of time. This is probably true for VBScript, but certainly not for Perl or Java....PHP is a truly remarkable and powerful system. I can see why it has become a popular system for producing Web sites.... I think that it will be a very strong competitor against Java and JSPs, and will rise significantly in my recommendations for clients and internal use."

PHP: Growing by the month

JSP enjoys the backing of Sun; hence its constant media attention. It is interesting to note that despite the lack of any publicity campaign, PHP's popularity is growing at a monthly rate of 8-11%, a percentage far greater than the Internet's 4% monthly growth -- as the demand for server-based applications has risen. More than 6.5 million sites use PHP (Netcraft May 2001 survey). PHP is used on 39% of Apache servers; Perl trails fourth, with 11% of the market. Apache maintains 59% of the Web server market; Microsoft IIS is second, with 28% of market share (E-Soft Inc./SecuritySpace's May 2001 report).

Prominent corporations using PHP include Unilever, Philips, NTT, Cisco, Japan Airlines, Air Canada, Lufthansa, GE Marketplace, Wallstreet:Online Germany; AuctionWatch, VillageVoice, Dialpad and BMC.

  1. Intranet Design Magazine: PHP From an IT Manager's Perspective, Jun 4, 2000. http://linuxtoday.com/news_story.php3?ltsn=2000-06-04-002-04-NW-HL-SW

  2. eWEEK: Four scripting languages speed development, October 30, 2000. http://www.zdnet.com/eweek/stories/general/0,11011,2646052,00.html

Next Previous Contents