02-start of a request with the end Korea end with beginning end with beginning of the picture with the beginning of AV first

Source: Internet
Author: User
Tags call back sapi
PHP will go through two main stages when it starts to execute:

    • The start phase before processing the request
    • The end stage after the request

The start phase has two processes:

The first procedure is the module initialization phase (MINIT), which is performed only once throughout the SAPI life cycle (for example, throughout the life cycle of Apache startup or during the entire execution of a command-line program).

The second process is the module activation phase (RINIT), which occurs during the request phase, such as requesting a page through a URL, and module activation before each request (Rinit request starts). For example, if PHP registers some extensions, it will call back the Minit function of all modules during the Minit phase. Modules can perform some initialization work at this stage, such as registering constants, defining classes used by modules, and so on.

The module implements these callback functions by following a macro when implemented:

PHP_MINIT_FUNCTION(myphpextension){    // 注册常量或者类等初始化操作    return SUCCESS; }

After the request arrives, PHP initializes the basic environment for executing the script, such as creating an execution environment, including a symbol table that holds the variable name and value contents of the PHP runtime, and a symbol table for all current functions and information such as classes. PHP then invokes all of the module's Rinit functions, and at this stage each module can perform some related operations, and the module's Rinit function is similar to the Minit callback function:

PHP_RINIT_FUNCTION(myphpextension){    // 例如记录请求开始时间    // 随后在请求结束的时候记录结束时间。这样我们就能够记录下处理请求所花费的时间了    return SUCCESS; }

After the request has been processed, the end stage is reached, and the general script executes to the end, or by calling the exit () or Die () function, PHP will go to the end stage. And the beginning of the corresponding, the end stage is divided into two links, one at the end of the request to deactivate the module (Rshuwdown, corresponding to Rinit), one at the end of the SAPI life cycle (Web server exit or command line script completion exit) when the module is closed (Mshutdown, Corresponds to Minit).

PHP_RSHUTDOWN_FUNCTION(myphpextension){    // 例如记录请求结束时间,并把相应的信息写入到日至文件中。    return SUCCESS; }

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the beginning and end of the 02-once request, including the start and end, 02 aspects of the content, I hope to be interested in the PHP tutorial friends helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.