PHP backwards compatibility

Today I was writing some code – which is actually suprisingly rare these days – and I was getting an error about a particular function not existing in PHP5, array_diff_key()

Luckily some body already thought about this and has ported a lot of the older functions into PHP classes that get bundled with Pear (which we use a lot).

So, my issue was quickly fixed by the insertion of these three lines:

if(!function_exists(‘array_diff_key’))
{
require_once ‘PHP/Compat/Function/array_diff_key.php’;
}

Good stuff.

http://pear.php.net/package/PHP_Compat


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *