PHP uses a one-pass compilation process in which it converts the source code into an operation code stream (which is then executed). Since compilation uses only one pass and does not create an AST, most of the optimizations usually performed by other languages would be very difficult to implement. Obviously, some simple optimizations are performed (for example, interning strings and pre-characters), but most “advanced” optimizations are simply not possible.
By the way, a very simple way to “optimize” the PHP code is to cache the created stream of the operation code using the APC extension so that it does not recreate every time the page is loaded: the compilation process is quite resource-intensive, and using APC can often slightly decrease the load on your processor.
NikiC
source share