To your first question, I'm sure it can only increase efficiency.
To the second, think the other way around possibly...
Within your script, do the following (or something along these lines):
Pull a list of your includes directory into an array ($all_functions in my

 $file is the script itself, i.e. if your script was myScript.php,
 $file would be /path/to/myScript.php, as if you were opening it from a

while ($filerow = fgets($file,1024))
     /** Parse for functions here, somewhat indepth logic) **/

    if (in_array($function,$all_functions) &&
        $included_files[] = $function;

Alternatively, don't have it as functions, use require()
require() gets executed ever time it is read, as if it were an actual part
of your script. Plus it uses whatever is defined in the script's existing
memory space (works great for chopping down the # of lines in huge while

----- Original Message -----
From: Dave [Hawk-Systems] <[EMAIL PROTECTED]>
Sent: Wednesday, December 11, 2002 10:40 AM

Subject: [PHP] Automatic include of files containing functions

> On a few sites we have used a master include or function file containing
all the
> unctions required for the site...  Some of these function files may
> 30-40 functions and some pages use only 1 function from the file.
> Would like to be a little more dynamic in our approach of this, and have
> moving all the functions into their own files...  for example moving
> from the functions.php file to a connectdb.php or file.
> Then for any particular php page, we would pull in only the functions that
> need for that particular page.  From a script/function management
> this would be ideal.
> Questions//
> What would this do as far as speed and efficiency (having to load 4 or 5
> includes/requires rather than one larger include that has 25 functions
> aren't needed or used)?
> Then the hard one...
> Is there a way to have the PHP script dynamically pull in the required
> files?  for example, have a function at the top of each page to include
> files required as a result of functions that exist in the script...  ie:
> page uses abc() 123() and so it include/require ./includes/abc.php and
> ./includes/123.php which contain the appropriate functions.
> OR
> is there an easier way to manage what is becoming an over abundance of
> for particular sites.
> Have gotten in the habit of creating a function for anything I have to do
> than 1 or 2 times on seperate pages just to speed and simplify code from a
> design and readability point of view.
> Appreciate any comments.
> Dave
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to