Re: calling functions from one or multiple files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ashley Sheridan wrote:
On Wed, 2008-09-24 at 12:37 -0400, b wrote:
Lamp Lists wrote:
Hi, 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".

When not using a framework (eg. Cake) i also usually keep a single
file and include it. I think it depends on how many functions you
have. If you've got a really huge functions.php and most of them
are used only in one or two scripts, then you probably shouldn't be
loading it into every script. Otherwise, i wouldn't be too
concerned about it.

Of course, you should also think about using classes if that makes
sense for what you're doing.

I tend to try and group functions I use on a site, with common ones going into a generic functions.php file. This avoid the problems of overly large function files included on every page, as chances are
you won't need every function.


Done that, but not so much anymore. It depends on how specialised the functions (and sections) are. Usually an administration section can do with a separate file (while also including the general one). But, for other areas, it'll work fine until you find that you need a function that's in another file.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux