You are here: Re: Dynamically load functions « PHP Programming Language « IT news, forums, messages
Re: Dynamically load functions

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.
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация