13.8. Changes in Functions

Some minor changes in functions break backward compatibility. There are countless other additions to functions and additional functions, but these do not affect compatibility between PHP 4 and PHP 5.

13.8.1. array_merge()

This function no longer accepts a non-array parameter as one of its arguments. In PHP 4, it was perfectly valid to use scalar types, like an integer or string (but not a variable representing “null”), as parameter. These types are happily included as an element in the resulting array. PHP 5 no longer supports this. If you use a scalar type, PHP 5 issues an error of type E_WARNING and return an empty array. You can see this behavior by comparing the output of this script from PHP 4 and PHP 5:

 <?php ...

Get PHP 5 Power Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.