note 92060 deleted from language.oop5.autoload by crell
| From: | crell@php.net | Date: | Mon, 04 Apr 2022 16:12:51 +0000 |
| Subject: | note 92060 deleted from language.oop5.autoload by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218035@lists.php.net to get a copy of this message | ||
Note Submitter: Peminator
----
My idea for autoloading FUNCTIONS however only in a weird way :
<?php
function ex($parms)
{
$argvar = func_get_args();
$func = $argvar[0];
$funcargs = array_slice($argvar,1);
if (function_exists($func))
{
$returnvalue = call_user_func_array($func,$funcargs);
}
else
{
$funcpath = "scripts/".$func.".php";
require_once($funcpath);
if (function_exists($func))
{
$returnvalue = call_user_func_array($func,$funcargs);
}
else
{
die "SORRY $func IS NOT USABLE";
}
}
// return returned value :-)
return $returnvalue;
}
?>
USAGE EXAMPLE:
must be caled using the X function giving the real function as first parameter, like:
$result = ex("add",1,2);
// returns 3 if add function defined in add.php sums the first and second parameter..