jonniejoejonson Posted July 28, 2009 Share Posted July 28, 2009 Is it better to write code with lots of include statements, or is it more intensive on the server having to get 10 pages rather than just one?... Obviously include stements = neater more mangable code, but are there performance issues? thanks to any responders Link to comment https://forums.phpfreaks.com/topic/167788-code-using-include-statements/ Share on other sites More sharing options...
patrickmvi Posted July 28, 2009 Share Posted July 28, 2009 I believe you have to strike a balance between includes and the amount of stuff you want to load. You should set it up in a way where you load include files of only needed code. I've seen all too often people including functions upon functions upon functions or classes upon classes upon classes for pages that never use them. Make sure to only include files that you know for sure will be used everywhere on the site on all pages. Other includes should be done when necessary. Link to comment https://forums.phpfreaks.com/topic/167788-code-using-include-statements/#findComment-884849 Share on other sites More sharing options...
Zyx Posted July 28, 2009 Share Posted July 28, 2009 The more files you load the greater performance loss does occur. Although the amount of loaded text seems to be the same, PHP must perform more disk operations to locate and open 10 files, instead of one. On the other hand, if your script loads too much unnecessary PHP code every request, it wastes time for parsing it. Modern PHP frameworks tend to have more smaller files loaded, when they are really needed. Frameworks are unsually huge scripts and it's better to load only the necessary stuff. Furthermore, if your server has an accelerator installed, this is not so big problem, because commonly used files are kept in memory in the precompiled form. Link to comment https://forums.phpfreaks.com/topic/167788-code-using-include-statements/#findComment-884854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.