PHP 5.3: welcome to release party in Munich

Today we continue our analysis of the most significant changes applied to the new PHP version.

Changing magic methods

Before the introduction of PHP 5.3, these methods could be marked not only as public but also as private, protected, static ones, etc. Starting with the 5.3 these methods (mentioned below) cannot be static and must be public only:

* __get ()
* __set ()
* __isset ()
* __unset ()
* __call ()

Ministry of Health warns

PHP has a list of functions that were marked for removal. Most of them are not common (PHP developers use them not very often), but nevertheless, you should check your code (they won’t work in the new version). These functions are:

* Call_user_method ()
* Call_user_method_array ()
* Define_syslog_variables ()
* Ereg ()
* Ereg_replace ()
* Eregi ()
* Eregi_replace ()
* Set_magic_quotes_runtime () / magic_quotes_runtime ()
* Session_register ()
* Session_unregister ()
* Session_is_registered ()
* Set_socket_blocking ()
* Split ()
* Spliti ()
* Sql_regcase ()

Moreover, some directives in PHP.INI suffer the same fate, now they will warn you (E_DEPRECATED) if you try to activate them:

* Define_syslog_variables
* Register_globals
* Register_long_arrays
* Safe_mode
* Magic_quotes_gpc
* Magic_quotes_runtime
* Magic_quotes_sybase

Surprises

In PHP 5.0, the method “is_a ()” was described as inadvisable (manuals recommended to use “instanceof”), but in spite of this fact “is_a ()” was not removed from the language. Furthermore now it works without E_DEPRECATED-warnings.

The following words were reserved:

* GOTO
* NAMESPACE

It is very unlikely that they were included in your code, however, it would be better for you to scan the code. These words cannot be used as function names, class names, etc.

Say hello to the new version of PHP! (Migrating to PHP 5.3)

We sure that some software specialists who develop PHP applications have already downloaded and started testing the new features of PHP 5.3. No doubt, this version can be considered as the major change in language over the past 7 years. But most of the developers are not interested in new features, which can be used for their future developments; first of all they worry about changes that can affect already written applications.

What was updated:

Good news for PHP developers who used to write code according to the current trends, your application will be affected only by a few changes. But those programmers, whose code was aimed at earlier versions of this language, should be so lucky! :) So, in this post and the next one we are going to describe some key points that deserve your attention (we hope you will find some useful tips here, especially if you are going to migrate from PHP 5.2.x to PHP 5.3.x).

Of course this list of updated features is not a complete one, more extensive information you’ll find in PHP 5.3 changelog.

More work with arrays:

Array functions in the previous PHP versions could work with arrays taking them as arguments, so you could indicate an array or an object as an argument. But you can’t do it in 5.3, many of array functions now can accept only arrays. If you want to get object properties using any of the options below, you will need to convert the object into array:

* Natsort ()
* Natcasesort ()
* Usort ()
* Uasort ()
* Uksort ()
* Array_flip ()
* Array_unique ()

…to be continued