23.02.2010, 18:30
Quote:The idea of what is a compiler seems to be a subject that causes great confusion. Some people assume that a compiler is a program that converts source code in one language into an executable program. The definition of what is a compiler is actually broader than that.
A compiler is a program that transforms source code into another representation of the code. The target representation is often machine code, but it may as well be source code in another language or even in the same language.
PHP became a compiled language in the year 2000, when PHP 4 was released for the first time. Until version 3, PHP source code was parsed and executed right away by the PHP interpreter.
PHP 4 introduced the the Zend engine. This engine splits the processing of PHP code into several phases. The first phase parses PHP source code and generates a binary representation of the PHP code known as Zend opcodes. Opcodes are sets of instructions similar to Java bytecodes. These opcodes are stored in memory. The second phase of Zend engine processing consists in executing the generated opcodes.
The Zend engine was built in such way that right after the first phase, the opcodes may be stored in the server shared memory space. This is done by special PHP extensions knows as opcode caching extensions. There are several PHP caching extensions also known as PHP accelerator extensions.
The purpose of these extensions is to skip the initial compilation step. If a PHP script was previously compiled and stored in shared memory, next time the same script is executed, the caching extension just loads the compiled opcodes from the shared memory very quickly. This way PHP gains a lot of time by skipping the initial opcode compilation step.
PHP is a compiled language since PHP 4.0
MfG
dispy