. # This function makes it easier to put everything in functions like you should. # # Instead of putting everything in the global namespace and having it run when # you include the file, put everything in functions. This function makes it so # you can both include (require_once) the file, and call its main function in # one easy step. # EXAMPLE # # list($user, $pass) = file_run('db_password.php'); # # the file db_password.php would be like so: # # function db_password_main() { # return array('me', 'secret'); # } function file_run($filename /* args... */) { $args = array_slice(func_get_args(), 1); require_once($filename); $func = basename($filename, '.php') . '_main'; if(function_exists($func)) { return call_user_func_array($func, $args); } } ?>