This article gives you the content is about the kernel in PHP and the implementation of PHP code introduction, there is a certain reference value, the need for friends can refer to, I hope to help you.
1, the core composition of PHP
PHP includes a total of 3 modules: PHP kernel, Zend Engine, PHP extension layer
1.1 PHP Kernel: Used to handle requests, file streams, error handling and other related processing.
1.2. Zend Engine: Convert source files to machine language and run on Zend virtual machines
The Zend is made up of two parts:
Compiler: Responsible for compiling PHP code into executable opcodes
Actuator: Responsible for executing the compiler output opcodes, which is the code logic written in the PHP script
1.3. Expansion
An extension layer is a set of functions, class libraries, and streams that PHP uses to perform specific operations, such as installing the PHP_OPENSSL extension to use the Open SSL function, a common extension,
The extension is installed in the PHP installation path ext directory.
2. PHP Code Execution process
The approximate execution process for PHP is as follows:
We write PHP code, is not able to directly execute, to go through the lexical, parser, and then compiled by the compiler, see here might want to tease me this is? is PHP not a scripting language? How do you still have to be compiled like C + +? In fact, strictly speaking, PHP is compiled language, after lexical parsing, then compiled, compiled into the opcode intermediate code, and then executed by the Zend execution engine, then from this point, PHP is compiled after the execution, this is similar to Java, but Java is the code (. Java) Compiled into bytecode, and then executed by the JVM.