note 18576 added to function.call-user-func-array
| From: | joejohnstonNOSPAM at simple10 dot NO_SPAM dot com | Date: | Mon, 28 Jan 2002 14:50:06 +0000 |
| Subject: | note 18576 added to function.call-user-func-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25918@lists.php.net to get a copy of this message | ||
If you're stuck on a virtual host using a PHP version older than 4.0.4, the following bit of
code may help you get PHP programs like Smarty (a caching template class) to work if they require
the use of call_user_func_array. I haven't tested it in PHP3, but it should work.
/**
* Define call_user_func_array if it does not exist
**/
if (! function_exists('call_user_func_array')) {
function call_user_func_array ($func, $ar) {
$funcCall = "$func(";
// Build function call string by adding each parameter
for ($i=0; $i<sizeof($ar); $i++) {
eval ("\$funcCall .= '\$ar[$i],';");
}
// Strip off last comma ','
$funcCall = substr($funcCall, 0, -1);
$funcCall .= ')';
eval("\$retval = $funcCall;");
return $retval;
}
}
You can get Smarty at http://www.phpinsider.com/php/code/Smarty/
However, you'll need to do some additional modifications to make it work under PHP versions
older than 4.0.4
--
http://www.php.net/manual/en/function.call-user-func-array.php
http://master.php.net/manage/user-notes.php?action=edit+18576
http://master.php.net/manage/user-notes.php?action=delete+18576
http://master.php.net/manage/user-notes.php?action=reject+18576