How does the zend engine compile php codes or how does the php compiler work?

Hi, any authority knows how the zend engine compiles php codes. E.g. in java, our codes are compiled into byte code, after which it is converted to machine language. how wise how does the zend engine compile php codes? Please help me.

+4
source share
2 answers

This is the same idea with PHP:

  • First step: PHP source code (i.e. some text) compiled into a set of opcodes
  • Second step: these opcodes are executed.


This compilation, by default, is executed every time a PHP script is to be executed - which some processor accepts.

For this reason, you can use some operation cache code (for example, the APC extension ) to save operation codes in memory - avoiding the redundant compilation step.


You can find interesting information about these processes in the next presentation by Sebastian Bergman: PHP internal compilers

+9
source

Zend Engine is used internally by PHP as a compiler and runtime engine. PHP scripts are loaded into memory and compiled into Zend opcodes. These opcodes are executed, and the generated HTML is sent to the client.

+1
source

Source: https://habr.com/ru/post/1344596/


All Articles