Sometimes having less included files with more content is more efficient than having a lot of small files [...]
I'd think in my case, this is true. Generally, nothing is in these main include files that aren't needed by every page.
I'd suggest profiling your code, use the PEAR Benchmark class and use PHP's memory usage functions to determine what parts of your code are consuming the most resources and taking the longest amount of time to execute, then try some experiments and profile each experiment to determine the most efficient solution.
Profiling is something I've been doing a lot of in the past week or so, via various debuggers. I wasn't aware of a PEAR Benchmarking class, I'll have to check it out.
In my commericial websites I have modified my application framework not to connect to the database, start output buffering, start the session and do other overhead if specific constants are declared. For example if I have contact.php that does some mailing stuff and requires Smarty I can define TEMPLATE_ONLY and only templating related files will be included and initialized.
Doing this optmization made pages roughly 50% faster that did not require session or a database connection and also reduces the load on the sql server because you are not connecting unless you actually need the connection and still benefit from having a single connection call instead of connecting in each function or file.
I have done similar things. For instance, sessions are only useful to me for people who are actually logged in, so I recently dumped my custom PHP sessions handler and made my own session system. It takes a lot less code than my handler and only connects to the database if the user sends over a session id. The database connection is then closed if the proceeding script doesn't need it or it is opened later if needed, in the case of no session. It creates a session only through the log-in script. This way, sessions are only created and read for those who choose to log in, which is obviously far, far less than %50 of visitors. In the end, it works out to the database only being opened when needed and I've found this to make dramatic difference, even on my sorry old local enviroment.
I'm glad to see this topic got so many different responses.
Thanks fellas - Rob Paxon
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php