Home >Backend Development >PHP Tutorial >Introduction to the kernel composition in php and the php code execution process

Introduction to the kernel composition in php and the php code execution process

不言
不言Original
2018-09-04 17:35:573901browse

This article brings you an introduction to the kernel composition in PHP and the PHP code execution process. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.


1. PHP kernel composition

php includes a total of 3 modules: php kernel, zend engine, PHP extension layer

1.1 PHP core: used to process requests, file streams, error handling and other related processing.
1.2. zend engine: convert the source file into machine language, and then run it on the zend virtual machine

zend is composed of two parts:
Compiler: responsible for compiling PHP code into a readable Executed opcodes
Executor: Responsible for executing the opcodes output by the compiler, that is, executing the code logic written in the php script

1.3. Extension
The extension layer is a set of functions, class libraries and Streams, PHP uses them to perform some specific operations, such as installing the php_openssl extension to use the open ssl function. Common extensions are,


Installed extensions in PHP The installation path is in the ext directory.

2. PHP code execution process

PHP 执行流程图

#The general execution process of PHP is as follows:
The PHP code we write cannot be executed directly , it must first go through the lexical and syntax analyzers, and then be compiled by the compiler. When you see this, you may think, are you kidding me? Isn’t php a scripting language? Why does it need to be compiled like C/C? In fact, strictly speaking, PHP is a compiled language. After lexical and syntactic analysis, it is compiled and compiled into opcode intermediate code, which is then executed by the zend execution engine. From this point of view, PHP is compiled first and then executed. It is very similar to java, but java compiles the code (.java) into bytecode and then executes it by the jvm.

Related recommendations:

PHP kernel decryption series: execution process of zend_execute

Execution of the interpreter for PHP kernel exploration process

The above is the detailed content of Introduction to the kernel composition in php and the php code execution process. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn