PHP has three types of modules which are as following.
A) Core PHP : This modules handles requests, error handling as well as file streams.
B) Zend Engine: It convert the php code into machine tokens or opcode and it will execute it in a virtual machine.
C) Extensions: It is bunch of functions, classes and streams made available in php script. One of the extension named mysql extension which is useful to make a connection with database.
When we start the Apache, it will start the php interpreter. Using mod_php5 module, PHP is linked with Apache. When page request is made then SAPI(Server API) gives the control to php layer and then php layer creates an environment for code execution. It will create a symbol table of variables which will be used at the time of page execution.
In next step PHP calls RINIT method of each modules. RINIT denotes to request initialization module. RINIT module implementation is cookie's module. If it is activated in php.ini, RINIT method of cookie module will populate the $_COOKIE variables and store in symbol table.
After page request completed, either by reaching the end of the script php starts the clear-up process. It calls RSHUTDOWN method of each extension. RSHUTDOWN method destroy the symbol table.
After that php calls MSHUTDOWN method of every extension and it frees the persistent memory allocated at the process of MINIT and it is the last chance to free the handlers for all extensions
Zend engines passes the control to PHP core, which provide that to SAPI layer and it will render the page in browser.
0 Comment(s)