On Tue, Jul 22, 2003 at 04:08:35AM +0500, Haseeb wrote:
>
>i like keeping all the functions in one file and the
> include the file whenever i need any function.
...
>some programmer that prefer to use only one file as front end and place
> switch or if conditions and include other files depending on the condition.
...
>divide the functions into files. and then include only that file
> that has the function.
I do a little of all three, myself. But, it depends on the project.
If the project is small enough, a single function file will do. I start
to segregate functions by category when I see logical divisions between
the functions. (I.e. billing things, statistical things, etc.) Then I
choose which function libaries to call based on whatever criteria I have
on hand -- usually user input.
Often it's simpler than that -- a project could have a "billing.php"
script that calls "functions-billing.php", and "stats.php" that calls
"functions-stats.php". And if a particular billing function wants to
use something out of stats, it can simply include that library.
Another thing I've done from time to time (though I wouldn't recommend
it) is name your function library after a variable that's used to denote
the part of the program you're running in. For example:
if (ereg('^[a-z]+$',$sect)) @include("functions-" . $sect . ".php");
That way, you're basing your include on something that you're already
managing, perhaps as a form or session variable. YMMV. Don't forget to
do your sanity checking. This method may be prone to security problems.
--
Paul Chvostek <[EMAIL PROTECTED]>
it.canada http://www.it.ca/
Free PHP web hosting! http://www.it.ca/web/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php