Speed optimization

As with many scripting languages, PHP scripts are normally kept as human-readable source code, even on production web servers. Therefore, these PHP scripts will be compiled at runtime by the PHP engine. Compiling at runtime increases the execution time of the script because it adds an extra step in runtime. PHP scripts can be compiled before runtime using PHP compilers just like other programming languages such as C (the programming language PHP is programmed in, and which is used to program PHP extensions).

Code optimizers improve the quality of the compiled code by reducing its size and making changes that can reduce the execution time and improve performance. The nature of the PHP compiler is such that there are often opportunities for code optimization, and an example of a code optimizer is the Zend Optimizer PHP extension.

PHP accelerators can offer significant performance gains by caching the compiled form of a PHP script in shared memory to avoid the overhead of parsing and compiling the code every time the script runs.