9.5. PHP Improvements

Once you've optimized your hardware, your database, and Apache, you can concentrate on tuning your actual code. The best preparation you can do to help yourself at this point is to select and adhere to a consistent coding standard. The less time you spend trying to interpret what you have written, the more time you can spend looking at other tricks to improve its efficiency.

9.5.1. Coding Standards

The visitors to your site have priority. Your job is to put the effort into getting them the information they want as rapidly as possible. On the other hand, your time is more valuable — indeed, more expensive — than the computer's.

If you can save yourself five minutes' work at the expense of an extra millisecond of processing time on a page, that is a good investment that would continue to pay off even after the page has been processed three hundred thousand times. You can put those five minutes into something more productive, such as seeing if there is a way to save twenty milliseconds when processing the page. It's not just a matter of being able to fill a user's request as fast as possible — considering all the opportunities for delay between your server and their browser, mere speed may not be that much of a factor. (It is if you have an extremely busy site, but if that's so then as you've seen your bottlenecks are probably elsewhere.) It's a matter of if you can get the existing page to run faster, you can start wondering what else the page could do for ...

Get Professional LAMP: Linux®, Apache, MySQL®, and PHP5 Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.