Jump to content

Functions vs Includes (for speed)


MrCat

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/234613-functions-vs-includes-for-speed/
Share on other sites

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.

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.