Re: where to put a function

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

 



On Mon, Apr 14, 2008 at 9:34 AM, Rick Pasotto <rick@xxxxxxxx> wrote:

> Probably been answered a thousand times; if so, just tell me where to
> look.
>
> I have a function that includes a specific sql query that is used on
> only one page on the site. Should that function be coded (1) in the page
> itself, (2) in a separate file that only that page includes, or (3) in a
> master file that contains all the functions used on the site and is
> included on every page?


each have their merits and detriments.
1. down-and-dirty, if  you put it here, you may have to move i later
2. more organized, somewhat future conscience, because now it can already be
used by other code simply by including the file
3. hmmm.  well, i would only put it in a file w/ other functions related to
it.  if you have a small app it could make sense to just toss a bunch of
seemingly random functions together in one file, but after a while that
could get pretty messy.

What is the cost of parsing a
> bunch of functions that are not used on a given page load?
>

not much, but less if you have an opcode cache.  i would be more worried
about code organization than performance on this one.

-nathan

[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