PHP life cycle

Source: Internet
Author: User
Tags sapi what php

A PHP instance, whether it is called from the init script or started from the command line, goes through the four processes of module INIT, request init, request shutdown, module shutdown, of course, This also executes the script's own logic, the two types of init and two shutdown each will execute how many times, the respective frequency of execution, depending on what PHP SAPI with the host communication, the most common four ways to start PHP are as follows:

1. Direct cli/cgi mode call

2. Multi-process Module

3. Multi-threaded module

4, embedded, in their own C program call Zend Engine

The SAPI (Server Abstraction Program Interface) provides an interface that allows PHP to interact with other applications, that is, PHP can interact with other programs such as Apache and this interface works

When you enter: Php-f test.php on the command line, the following procedure occurs

1, the registration of constants or class initialization work

2. Request the test.php file, when the request arrives, PHP initializes the underlying environment for executing the script, such as creating an execution environment, including a symbol table that holds the variable name and variable value contents of the PHP runtime, and a symbol table for all current functions and classes, and then PHP invokes the Rinit function for all modules, at this stage Individual modules can also perform a number of related operations.

3, the implementation of the test.php phase, the main is to edit the php file into opcodes, and then execute under the PHP virtual machine

4, the request after processing into the end stage, the general script execution to the end of the Exit function, and the beginning of the corresponding phase, the end stage is divided into two links, one at the end of the request, one at the end of the SAPI life cycle

From PHP core technologies and best practices

PHP life cycle

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.