3 # This program is in the public domain within the United States. Additionally,
4 # we waive copyright and related rights in the work worldwide through the CC0
5 # 1.0 Universal public domain dedication, which can be found at
6 # http://creativecommons.org/publicdomain/zero/1.0/
9 # This function makes it easier to put everything in functions like you should.
11 # Instead of putting everything in the global namespace and having it run when
12 # you include the file, put everything in functions. This function makes it so
13 # you can both include (require_once) the file, and call its main function in
18 # list($user, $pass) = file_run('db_password.php');
20 # the file db_password.php would be like so:
22 # function db_password_main() {
23 # return array('me', 'secret');
26 function file_run($filename /* args... */) {
27 $args = array_slice(func_get_args(), 1);
28 require_once($filename);
29 $func = basename($filename, '.php') . '_main';
31 if(function_exists($func)) {
32 return call_user_func_array($func, $args);