Created
December 16, 2011 20:20
-
-
Save Darkflib/1487788 to your computer and use it in GitHub Desktop.
plugins in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
print_r($_SERVER); | |
define('PLUGINDIR','./plugin.d/'); | |
foreach (glob(PLUGINDIR."*.php") as $filename) { | |
require_once($filename); | |
$basename=substr($filename,strlen(PLUGINDIR),-4); | |
$funcname='plugin_'.$basename; | |
$result[$basename]=$funcname(); | |
} | |
$jsonresult = json_encode($result); | |
echo $jsonresult."\n"; | |
?> | |
//...and a plugin... | |
<?php | |
function plugin_mike() { | |
$foo=array(); | |
for ($i=1;$i<=20;$i++) { | |
$foo[]=md5($i); | |
} | |
return array('aardvarks' => "mike", 'foo' => $foo); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment