In this section, I review a variety of things that contribute
to writing efficient code, whether in PHP or another
language. Note that some of the following suggestions may, in the minds of some
people, reduce the readability of the code. However, the payoff is
in terms of improved performance.
You, as the developer, determine the points in an
application where performance or readability and maintainability are the primary
concerns. For example, if a piece of code is executed once per instance of
an application, then readability is probably most important. However, for
a piece of code that may be executed thousands, even millions of times per
application instance, then performance is probably of greater
importance than readability. Even this depends on a number of
external factors -- such as the time available to execute that piece of the
application, the amount of work to be done during each
iteration, and the users' perceived performance of that part of the
application.
If you do apply any of these techniques for improved performance, and
you think it negatively impacts the readability of the code, add
extra comments to the code and explain what is happening.