Re: [PHP] calling functions from one or multiple files
- From: ash@xxxxxxxxxxxxxxxxxxxx (Ashley Sheridan)
- Date: Wed, 24 Sep 2008 18:52:56 +0100
On Wed, 2008-09-24 at 20:32 +0300, Thodoris wrote:
Ah maybe I wasn't clear but that's what I meant by grouping the
On Wed, 2008-09-24 at 12:37 -0400, b wrote:I was using the same method until now but functions.php grew so much
Lamp Lists wrote:I tend to try and group functions I use on a site, with common ones
Hi,When not using a framework (eg. Cake) i also usually keep a single file
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".
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.
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.
Ash
www.ashleysheridan.co.uk
that made my life difficult. The solution was to break down this file
into smaller files that each included a category like:
web.php
db.php
math.php
client.php
user.php
session.php
etc.
This made my life easier since I can edit and maintain the separate
files more efficiently and I didn't have to include the whole API
every time but only the files I really need. A good thing was to put
these files into a separate dir which I named include.
Same thing applies to classes I guess which is probably the next step.
Thodoris
functions. Generic ones that are used on all pages go into functions.php
and others go into other function includes. So I might have one that
deals with my blog, other for images, etc, depending on the project in
question.
Ash
www.ashleysheridan.co.uk
.
- References:
- calling functions from one or multiple files
- From: Lamp Lists
- Re: [PHP] calling functions from one or multiple files
- From: b
- Re: [PHP] calling functions from one or multiple files
- From: Ashley Sheridan
- Re: [PHP] calling functions from one or multiple files
- From: Thodoris
- calling functions from one or multiple files
- Prev by Date: Re: [PHP] spreadsheets are opened read only
- Next by Date: Don't understand what is this $arr['N']['#']
- Previous by thread: Re: [PHP] calling functions from one or multiple files
- Next by thread: Re: [PHP] calling functions from one or multiple files
- Index(es):