Hi all.
I have need to dynamically load some classes. I have created an
abstract class that defines a function. Note that I'm using PHP 4 so
abstract is not enforced. 3rd party plugins will then implement this
interface. Users will upload their plugins via a web interface. After
I save the php class file to the directory ./plugins, I will need to
load it later. Basically I need to do something like.


$dir = dir("plugins");

while($entry=$dir->read() ) {

    //skip non class php files.
    if(!eregi(".+\.class\.php$", $entry )) {
        continue;
    }//end if

    //dynamically load class and call it

    //require class
    require_once("plugins/".$entry);


    //get the class name from the entry

    $classname = ??? ?;

    $plugin = new $classname();

    //result array
    $results = $plugin->getObjects();

    //do other stuff

}//end while

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to