Tag Archives: Call_user_func_array

call_user_func(_array) behaviour in PHP 5.3

Before PHP 5.3 you could use call_user_func and call_user_func_array even if you didnt provide an array with parameters. Since 5.3, this results in a ‘NULL’ without actually executing this method/function.

// works in < 5.3, but fails in > 5.3
$moduleItems = call_user_func_array(array($className, ‘getByTag’), $this->id);

// works everywhere
$moduleItems = call_user_func(array($className, ‘getByTag’), $this->id);

In all honesty, it’s normal that it shouldn’t work when you don’t provide the right parameters. However a decent notice would let me know that something is wrong.