The new OOP additions in PHP 5

Feb 25, 2009

The community evolved around PHP has helped the scripting language reach the 5th version in July 2004, in which they have included various object oriented features, resulting into a better language that can provide sophisticated Web-based applications.

In the area of object oriented features, PHP 5 passes objects by reference, which is more efficient than having to duplicate memory structures. The 5th PHP version offers extended object-oriented support (such as providing the  INSTANCEOF keyword), and better constructors and destructors. It also provides private and protected variables and other popular OOP features, such as abstract classes (which enable developers to build prototype classes).

Other syntax improvements include the FINAL keyword, which prevents the subclassing of a member function, the  CONSTANT keyword, and complex exception handling with the  TRY, CATCH, and THROW keywords. As an example, in an error occurred during the execution of a program, if TRY was used, then the  CATCH section should warn the developer about it.

Another included functionality is function overloading, which allows developers to create several different implementations for the same function, while using different input variables. This is different from using default values, which are used only when arguments are not specified. The important aspect about this feature, is that the programming engine will determine which function was meant to be called, at runtime, according to the types of the variables used to call it.

The latest PHP version is clearly a useful tool. Coupled by the fact that it's released in the open source community, it appeals to a wide range of developers that would rather choose a development environment with less restrictions on implementation and lower costs, over a more competitive, professional development tool like ASP.NET.

The bottom line in free versus licensed development languages is about improvements, and although PHP and other open source programming tools are constantly upgraded by their communities, these upgrades are nevertheless slower and bulkier, since they are made by different groups of persons scattered over the web, with no central management control or supervision.

Which brings us to a fundamental issue in website management. As we entered the year of 2009 in the gloomy horizon of the world wide financial crisis, many businesses are trying to cut costs by moving to open source, no costs servers and development tools. This is effective in terms of financial costs, over the short term, but when we speak in terms of human resources (training, getting people to work in PHP, lowering turn-over rates) may result in higher costs over the long term than previously expected. Well, maybe a lot of people will start liking PHP better so this will not be a problem, but then again, it's hard to count on people's likes and dislikes when a business is at stake.

Another major concern would be the liability issues. When using free stuff for your business, don't expect for someone else to be held responsible when things go wrong. Because there isn't any “official” contract between you and open source creators. Whereas, in a binding contract between a supplier (Microsoft) and the business owner, the latter is secured against failures by Microsoft's liability for its products. This explains the higher costs of .NET servers. But costs are not the only thing the .NET technology is known for. Keep reading to see what ASP.NET actually provides for developers.


Introduction - PHP and ASP.NET - Making the right choice
1. The new OOP additions in PHP 5
2. What ASP.NET provides on top of that
3. PHP features
4. ASP.NET features