note 18576 deleted from function.call-user-func-array by aidan
| From: | aidan@php.net | Date: | Thu, 17 Jun 2004 00:35:14 +0000 |
| Subject: | note 18576 deleted from function.call-user-func-array by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71173@lists.php.net to get a copy of this message | ||
Note Submitter: joejohnstonNOSPAM@simple10.NO_SPAM.com
----
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.
<?php
/**
* 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
?>