Several function file includes in PHP?

If you care about performance install an opcocde cche like APC which will save the compiled form of the script in memory.

If you care about performance install an opcocde cche like APC which will save the compiled form of the script in memory. If you don't want to install APC the difference is minimal, yes accessing less files takes less time, but that's not where most of the time is spent. (Especially as the filesystem should be able to cache the scripts (uncompiled) in memory) if they are requested often enough.

Yes, APC is the best way for many includes. – Franz Dec 1 '09 at 14:45.

Calling include/require function 5 times instead of 12 time is not so different, what is important is content of the included file(s). Also, include cahchers are well suit for your purpose such as APC or xcache.

I would even suggest to split them into much more files. Look at the MVC pattern, or other frameworks, they are extremly splitted, so you easily can maintain "only" parts, without worrying about destroying something, as long as you follow your structure.

Some points to consider that I think about also Rasmus Lerdorf has said frequently that "you shouldn't have more than about five includes". I can only assume that he knows what he's talking about, because he made PHP. I am skeptical about the feasibility of this, however.

Especially on large projects. I've found that it's better for development and milestones to make life easier on your developers. If that means separate files, then that's a good idea.

If you're worried about CPU usage or bandwidth, there are probably more obvious bottlenecks than liberal use of include. Un-optimized functions are a good way to make the app faster, and paying attention to images and css or js files is a good way to reduce bandwidth.

Lol, funny typo. – Franz Dec 1 '09 at 14:47 Rasmus tends to have overly ortodox opinions, though. :) – Emil H Dec 1 '09 at 14:48 @franz - way too early for me to be coherent.

;) Should have been "optimizing unoptimized functions" – davethegr8 Dec 1 '09 at 16:32.

With vanilla PHP it is generally better to use as few include files as possible, but of course that makes maintenance a pain. Use an opcode cache such as APC and the performance problem will pretty much disappear. Also, 12 files isn't a very large number of includes, compared to the large MVC-frameworks and other libraries.

Keeping the functions separated in a logical structure is the best way by far.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions