JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
changed licence to lgpl, metaform includes wfpl in tarbal
[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 under the
8 #  terms of the GNU Lesser General Public License as published by the Free
9 #  Software Foundation; either version 2.1 of the License, or (at your option)
10 #  any later version.
11 #
12 #  wfpl is distributed in the hope that it will be useful, but WITHOUT ANY
13 #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 #  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
15 #  more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public License
18 #  along with wfpl; if not, write to the Free Software Foundation, Inc., 51
19 #  Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
21
22 # This function makes it easier to put everything in functions like you should.
23 #
24 # Instead of putting everything in the global namespace and having it run when
25 # you include the file, put everything in functions. This function makes it so
26 # you can both include (require_once) the file, and call its main function in
27 # one easy step.
28
29 # EXAMPLE
30 #
31 # list($user, $pass) = file_run('db_password.php');
32 #
33 # the file db_password.php would be like so:
34 #
35 #     function db_password() {
36 #           return array('me', 'secret');
37 #     }
38
39 function file_run($filename) {
40     require_once($filename);
41     ereg_replace('.*/', '', $filename);
42     $func = basename($filename, '.php');
43     return $func();
44 }
45
46 ?>