PHP Core Journey - 1. Life Cycle

1. SAPI interface

PHP specific application programming interface.

2. Begin and end

  After PHP starts executing, it goes through two main stages:

    The start phase before processing the request and the end phase after the request.

      1.1 Beginning stage:

        1.1.1 Module initialization phase (MINT), only once.

        1.1.2 Module activation stage (RINIT), PHP will call the RINIT function of all modules

      1.2 End stage (PHP will enter the end stage when the script is executed to the end or by calling the exit() or die() function)

        1.2.1 Disable module (RSHUTDOWN, corresponding to RINIT)

        1.2.2 Close the module (MSHUTDOWN, corresponding to MINIT), when the web server exits or when the command line script is executed and exits

3. Single process SAPI life cycle

  PHP in CLI/CGI mode belongs to the single-process SAPI mode. Close after processing a request.

PHP also does a lot of work between stages.

(1) Start

(2) Initialize several global variables

(3) Initialize some constants

(4) Initialize Zend engine and harmony components

(5) Parse php.ini

(6) Initialization of global operation functions

(7) Initialize statically built modules and shared modules (MINIT)

(8) Disable functions and classes

(9)ACTIVATION

(10) Activate Zend Engine

(11) Activate SAPI

(12) Environment initialization

(13) Module request initialization

(14) Running

  The php_execute_script function contains the entire process of running a PHP script

(15)DEACTIVATION

(16)flush

  sapi_flush flushes the last content

(17) Turn off the Zend engine

4. Multi-process SAPI life cycle

 

 5. Zend Engine

The Zend engine is the core of the PHP implementation and provides the infrastructure for the language implementation.

  PHP syntax time limit, script compilation and runtime environment, extension mechanism and memory management.

  Many PHP extensions use the Zend API, and Zend is the implementation of the PHP language itself. PHP just uses the Zend core to build the PHP language.

 

Reference: http://www.php-internals.com/book/?p=chapt02/02-01-php-life-cycle-and-zend-engine


Author: Jackson0714 Source: http://www.cnblogs.com/jackson0714/ About the author: Focus on the project development of the Microsoft platform. If you have any questions or suggestions, please let me know! Copyright statement: The copyright of this article belongs to the author and the blog garden. Reprints are welcome, but this statement must be retained without the author's consent, and a link to the original text is given in an obvious position on the article page. Hereby declare: All comments and private messages will be replied in the first time. We also welcome the gardeners to correct their mistakes and make progress together. Or directly send me a private message to support the blogger: If you think the article is helpful to you, you can click [ Recommend ] in the lower right corner of the article . Your encouragement is the biggest motivation for authors to persist in originality and continuous writing!





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324726854&siteId=291194637