|
Posted by Tony Marston on 10/04/06 07:53
You are working on the assumption that it is inefficient to include() a file
containing a function when your code never actually calls that function. The
trick is *not* to put each function in its own file, but to group them
together into a small number of files. That way you only have a small number
of include()s, and the fact that you only execute a small number of those
functions is irrelevant.
The idea that you should only include() a function's definition just before
you want to use it is totally misguided. That takes too much code for the
developer to type in, and *THAT* is inefficient.
The overhead of include()ing a function that you don't actually use is
sooooooo small that you can barely measure it, so don't bother. Concentrate
your mind on things that *really* matter.
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
<howachen@gmail.com> wrote in message
news:1159880983.906938.133440@h48g2000cwc.googlegroups.com...
>I have a function foo(), I want all my page can call this method
> without include / require
>
> I know I can set in php.ini by setting the auto_prepend...
>
> but this will cause overhead as every file need to prepend this file
> even no call to the function,
>
> are there any better method?
>
> instead of writting an extension?
>
> thanks.
>
Navigation:
[Reply to this message]
|