MrCat Posted April 24, 2011 Share Posted April 24, 2011 My programming technique has tended to be short pieces of code as separate files, and then including them in a main page. I like this from a management point of view because it makes things easier to read than scrolling through long files. I've been wondering if I should worry about any extra server load or time penalty in doing this? Should I switch my style to longer files that contain multiple functions? Quote Link to comment https://forums.phpfreaks.com/topic/234613-functions-vs-includes-for-speed/ Share on other sites More sharing options...
lastkarrde Posted April 24, 2011 Share Posted April 24, 2011 No. Keep things the way you are doing them. The benefit gained from code maintainability/readability is far greater than that of a minuscule performance hit. If you do start serving millions of requests, a bytecode cache such as APC will improve performance. Quote Link to comment https://forums.phpfreaks.com/topic/234613-functions-vs-includes-for-speed/#findComment-1205672 Share on other sites More sharing options...
MrCat Posted April 27, 2011 Author Share Posted April 27, 2011 Thanks for that comment - much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/234613-functions-vs-includes-for-speed/#findComment-1206694 Share on other sites More sharing options...
RopeADope Posted May 4, 2011 Share Posted May 4, 2011 Just a side note...you may already do this...but I inevitably wind up with huge files mostly because I group things by logical function. What I've always done is use tags and just search for the tags. Ex: <?php //Tags: post,print array, processing function myFunction(){ echo "Doing some processing..."; print_r($_POST); } //10,000 lines later... //Tags: mysql, query, last function lastFunction(){ echo "This is the last function, I swear..."; mysql_query(); mysql_close(); } Its obviously a very manual way to do it but its definitely easy to just "Find" a tag than to find something by scanning. Quote Link to comment https://forums.phpfreaks.com/topic/234613-functions-vs-includes-for-speed/#findComment-1210335 Share on other sites More sharing options...
MrCat Posted May 4, 2011 Author Share Posted May 4, 2011 Good idea. I haven't used comments enough in the past. Scripts always seem to end up more complicated than anticipated! Quote Link to comment https://forums.phpfreaks.com/topic/234613-functions-vs-includes-for-speed/#findComment-1210575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.