What’s new in PHP 5.3

Posted on March 27th, 2009 by Sam

With PHP 5.3 slated for release near the end of April (Q1 2009), it’s time to start looking at the new improvements being implemented. Version 5.3 was originally known as “PHP 6 without Unicode support”, but there are many new features being implemented in this release that have been on the development table for a few years. Conceptually the 5.3 release is directing developers towards the eventual release of version 6, which will be deprecating a lot of old features, fixing issues revolving around the core PHP structure, as well as tidying up many of the existing features.

Back in 2004, when PHP 5 was released, the updates were seen as enormous improvements in OOP and design. The updates included such needed additions as class-reflection, various class magic methods, and type hinting; allowing more dynamic design patterns. These new capabilities assisted significantly in advancing PHP towards business-level environment development and a stronger OOP language.

Incrementally adding new features has always been the way of PHP. As a completely open source scripting language, which has a very large group of contributers, the support of corporate entities, and a contentiously updated core, this seems to be an effective methodology for introducing changes. For PHP 5.3 these improvements come in the form of stability, performance improvements (through core refactoring) and syntax additions and extensions.

The following is a summary list of updates and changes to the language, more information on select changes will be covered in future articles. An article on Namespaces has already been posted for more information.

  • Support for namespaces
  • Late static binding
  • Lambda functions and closures
  • Optional cyclic garbage collection providing cyclic reference cleaning
  • New classes added
  • Improvements to existing extensions: openssl, spl and date
  • Changes to method signatures affecting backwards compatibility
    • __get(), __set(), __isset(), __unset(), __call() magic methods should be public now and can not be static, argument signatures enforced.
    • __toString() magic method can not accept parameters.
    • __callStatic() is a new magic method.
    • count() vs count_elements handler resolution rules change
    • __invoke (‘class fail { function __invoke() { echo “hello world”; } } $o = new fail; $o();’)
  • Syntax additions: NOWDOC, limited GOTO, ternary short cut “?:”
  • Several enhancements to enable more flexiblity in php.ini (and ini parsing in general)
  • Under the hood performance improvements
  • More consistent float rounding
  • Deprecation notices are now handle via E_DEPRECATED (part of E_ALL) instead of the E_STRICT error level
  • Optional support for the MySQLnd PHP native replacement for libmysql
  • Windows older than Windows 2000 (Windows 98, NT4, etc.) are not supported anymore
  • Improved windows support including VC6 and VC9 binaries
  • New bundled extensions: fileinfo, intl, phar, enchant, sqlite3

This release also drops several extensions and unifies usage of internal APIs. Users should be aware of the following known backwards compatibility breaks:

  • Parameter parsing API unification will cause some functions to behave more or less strict when it comes to type juggling
  • Removed the following extensions: mhash, msql, pspell, sybase
  • Moved the following extensions to PECL: ming, fbsql, ncurses, fdf
  • Removed zend.ze1_compatibility_mode

For full, in-depth list of changes in PHP 5.3 see the upgrading guide or the CVS NEWS file.

Leave a Reply