In PHP4, this function converts its return values to lowercase; but in PHP5, it leaves the return values in their original case. This can cause serious problems when trying to write code that dynamically calls a class method, and that works in both PHP4 and PHP5. This code snippet shows one way of achieving compatibility with both versions:
<?php
$className = 'SomeClass';
$methodName= 'someMethod';
$args = array('arg1', 'arg2');
$classMethods = array_map(strtolower, get_class_methods($className));
if (!$classMethods) {
$classMethods = array();
}
if (in_array(strtolower($methodName), $classMethods)) {
return call_user_func_array(array($className, $methodName), $args);
}
?>