[eluser]tonanbarbarian[/eluser]
1. no closing ?>
Every time you have a <?php and ?> tag PHP has to switch between PHP code and HTML processing.
So if you have a file which is mostly code, i.e. it starts with <?php and the last line of code in the file is php code, then if you add the ?> at the end of the PHP will switch to HMTL processing.
Now if you have your main script file that includes a second file, if that second file ends with ?>, then PHP will switch to HTML processing after it has passed that file, then when it comes back to the original script file it will have to switch back to PHP processing again.
This all takes time.
However I believe this issue has been resolved or at least lessened somewhat in the newer versions of PHP i.e. 5+, but I have not tested this,
Still good habbit not to end with ?> if not needed.
2. many smaller PHP files is only better than 1 big file if it reduces overall the amount of code loaded
for example if you have a library file that you include that has 1000 lines of code, but each time the library is called only 200 lines on average is used by any given page, it would be better to break that into 2 or more libraries so they can be loaded just as they are needed and there is not any excess code that is not needed being passed.
It is not always possible to do this, but if it is possible it can improve the performance of your code.
For a practical example
If you have a controller that has 4 methods in it, each 200 lines+ of code to process
By general practice CI only really runs 1 method in a controller at a time, so that means 3/4 of the code in the controller is not used for any given request. All of the code that is in the controller must be passed however and that uses memory and CPU cycles and therefore time.
If you put each of the 4 methods into seperate libraries and then modified the original methods to load the corresponding library and execute it the size of the controller would come down dramitically from 800+ lines of code to maybe 20.
Then the library would be loaded with its 200 lines of code.
So 220 lines of code would be loaded rather than 800
You can also do similar to this in the loading of any CI resources. Resist the tempation to autoload anything (unless you have something which is in every page such as the url_helper, authentication libraries etc). Because if you have a method in a controller that simply redirects the user to another page and you are loading helpers and other resources such as models etc that are not used, you are again wasting resources.
While the autoload feature is good it is better to load things as you need them, you know what you need as you are coding so load it before you need it and you will use less resources.