RE: [PHP] calling functions from one or multiple files
| From: | Robert Cummings | Date: | Wed, 24 Sep 2008 19:44:57 +0000 |
| Subject: | RE: [PHP] calling functions from one or multiple files | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280873@lists.php.net to get a copy of this message | ||
On Wed, 2008-09-24 at 13:58 -0500, Richard Lynch wrote:
> > -----Original Message-----
> > Right now I use one file, usually called functions.php, with all
> > functions I'm going to use most likely on every page.
> > Then, I create each function I'm going to use once in a while as
> > separate file.
> > Pro: I would include a function when I'm going to use.
> > Con: I have to write extra include line to call function. And have
> > bunch of files (functions) in function folder.
> >
> > I was talking to co-workers few days ago and they said I complicate my
> > life to much and putting ALL functions in one file is just fine and
> > I'll not be able to see difference in "real situations".
>
> You'd have to have a LOT of functions either way to make a difference...
>
> Actually, it's probably more expensive to open up the individual function files than to
> toss ~30 more functions into a single file.
>
> You'll have to profile 'require' on your own hardware to turn ~30 into a real
> number...
Seems kind of silly to have every function in it's own file. Also seems
kind of cluttered ot have every function in one file.
Now grouping related functions into a single file... that's sounds like
a good middle ground.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP