JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
major updates to db.php, added session.php, run.php uses file_run.php
[wfpl.git] / file_run.php
1 <?
2
3 #  Copyright (C) 2005 Jason Woofenden
4 #
5 #  This file is part of wfpl.
6 #
7 #  wfpl is free software; you can redistribute it and/or modify it
8 #  under the terms of the GNU General Public License as published by
9 #  the Free Software Foundation; either version 2, or (at your option)
10 #  any later version.
11 #
12 #  wfpl is distributed in the hope that it will be useful, but
13 #  WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  General Public License for more details.
16 #
17 #  You should have received a copy of the GNU General Public License
18 #  along with wfpl; see the file COPYING.  If not, write to the
19 #  Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 #  MA 02111-1307, USA.
21
22
23 # This function makes it easier to put everything in functions like you should.
24 #
25 # Instead of putting everything in the global namespace and having it run when
26 # you include the file, put everything in functions. This function makes it so
27 # you can both include (require_once) the file, and call its main function in
28 # one easy step.
29
30 # EXAMPLE
31 #
32 # list($user, $pass) = file_run('db_password.php');
33 #
34 # the file db_password.php would be like so:
35 #
36 #     function db_password() {
37 #           return array('me', 'secret');
38 #     }
39
40 function file_run($filename) {
41     require_once($filename);
42     ereg_replace('.*/', '', $filename);
43     $func = basename($filename, '.php');
44     return $func();
45 }
46
47 ?>