General Question

tantaikooi's avatar

Does including a file with lots of functions slow down PHP applications?

Asked by tantaikooi (122points) February 7th, 2008

In PHP, include a file with a lot of functions when u only use let say half of it.

But the reason to do it because if application go bigger, i don’t have to include many files.. just one is enough.

let say, i can include
userFunction.php – login, register, edit account…
dataFunction.php – all the activities related to data.

so in the page like add new data, i just include dataFunction.php…

Observing members: 0 Composing members: 0

4 Answers

iTony's avatar

It is always better to short the calls to the server, so it is a good practice to keep it in one file and one call. But also the the size of the file been called sometimes slows down more than having individual calls. To find out the happy middle I would use Firebug plugin in Firefox to find the time periods of the requests to the server. There is also PHPSpeedy that makes the requests significantly faster.

jrpowell's avatar

I would continue doing what you are. I would focus on making it the easiest to edit your site.

If the site loads reasonably well and and is easy to maintain I wouldn’t change what you are doing. But really, computers are fast enough now that parsing a few extra functions isn’t going to make much of a difference. Reading from the hard drive is a different story. I would rather have the CPU do more work and read the Hard Drive less. So I wouldn’t over manage your functions. Just try to keep it logical and organized.

tantaikooi's avatar

@iTony, one call? means call the function or include the file? and thanks for the useful tips! just installed firebug and it’s really great..and for PHPspeedy, have anyone here tried b4?

@johnpowell, ya i think one file is easier…just worried that i included too many functions and may seems not optimize. I gonna trust you that rather let the CPU do more work than hard drive do…

I make it this way, one dataFunction.php(include file) contains all the data manipulation functions, then i just include it, and call any of the functions inside of it, reusing it..does it make sense?


cwilbur's avatar

Write the code so that it’s easy to read and understand. If performance is unacceptable, then revise it. In PHP’s case, that can mean using something like the Zend Optimizer.

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther