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.