PHP Plugins with Classes
15
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);
}
}
$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);
}
}
Comments
Voting
Votes Up
adorkable81
albud
BrandonReese
ColdKeyboard
ctiggerf
dannyboy
i_kenneth
Pio
ray73864
SecondV
shachi
sphearion
sundaramkumar
wiz1705






There are currently no comments for this snippet.