|
Posted by Bob Stearns on 12/18/36 11:51
Thank you. This something along the lines I was thinking. I still have
to change every function invocation, but only minimally, and if I must
then I must.
However I have some questions. I am an ancient dinosaur (retired after
more than 40 years of programming and related activities) and have not
played with the OOP features of PHP.
1 where is the (privileged, I would think, starting with '__') function
'__autoload' referenced?
2 $includeMap should contain 1 entry for each function I wish to
reference, right? Why is it not private instead of public?
3 Is the function '__call' an override of a virtual function which is
used to do the actual calling of functions in objects, after converting
the argument list to an array (merging default parameters? )?
4 Is the function 'call_user_func_array' the actual system function
calling routine?
5 A matter of curiosity: are the system built in function arranged in
classes that should be over ridden like this for purposes of
instrumentation or further argument validation?
> I was thinking somet a bit more like this:
>
> function __autoload($c) {
> switch($c) {
> case 'Utility':
> include('Utility.class.php');
> }
> }
>
> overload('Utility');
>
> class Utility {
> public static $includeMap = array('myfunc'=>'myfunc.function.php');
>
> public function __call($m,$a,&$r) {
> if(!function_exists($m)) {
> include(self::$includeMap[$m]);
> }
> $r = call_user_func_array($m,$a);
> return true;
> }
> }
> then you do:
> Utility::myfunc();
>
> Of course, you'd have to prefix all the function calls with Utility or
> what not.
>
[Back to original message]
|