Josh Mc
Josh Mc

Reputation: 10254

Is it quicker to not load/include many files in php?

I have about a 2000 line functions file, and I have realized I can split it up into a bout 4 files, and only include the one's required. At the moment it is very neat, and ideally I would like to leave it that way, however if speed increases can be gained I would like to only include the different sections on particular conditions.

My question is basically, would it be quicker to have an if statement and only load the php functions needed. Speed is a factor, as this library is called in an ajax polling situation.

Upvotes: 3

Views: 229

Answers (1)

Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53606

best approach would be to divide all your code into meaningful folders/files/classes/functions. This serves the purpose of maintainable and readable code.
And then use some kind of cache like APC whih removes the problem of many includes/IOs almost completely.

Upvotes: 6

Related Questions