Re: where to put a function

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

 



Rick Pasotto írta:
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?

I've been doing #1 (not actually a function in this case) but #3 is
appealing, especially since I would implement it as OOP and the page
itself would be really just a template. What is the cost of parsing a
bunch of functions that are not used on a given page load?



Q: where to put a function?
A: into the class where it belongs.

sorry I could not stand it ;)

to be more serious, one giant 'functions.php' include file is not a very good solution, because you might end up including dozens of unused functions in every page.

on the other hand, putting it into the page doesn't let you use it anywhere else.

so the solution should be somewhat like the oop class organization: put together those that are logically belonging together. this way you'll have libraries for each type of functions, and only include what you need

greets,
Zoltán Németh


--
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