PHP Plugins with Classes





15
Date Submitted Mon. Oct. 9th, 2006 2:49 PM
Revision 1 of 1
Scripter wiz1705
Tags classes | PHP | plugins
Comments 0 comments
Basic internal class loading for PHP. Could make some plugins with this code if used properly.
$d = dir('plugins');
$somevar = "yaay, it works!";

while (($entry = $d->read()) != false) {
        // make sure the file isn't the current dir or the parent dir
        if ($entry != "." && $entry != "..") {
                // get the class name from the file name
                $class = str_replace(".php", "", $entry);
                // include the plugin
                include 'plugins/' . $entry;

                $instance = new $class();
                // now we can call anything in that class if it exists!
                $instance->invokeSomething($somevar);
        }
}

Zachary Howe

autoignition.net

Comments

There are currently no comments for this snippet.

Voting