PHP程式的執行流程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
static void
php_init_handler(server_rec *s, pool *p)
{
register_cleanup(p,
NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec); if (!apache_php_initialized)
{
apache_php_initialized
= 1;
#ifdef
ZTS
tsrm_startup(1,
1, 0, NULL);
# endif
sapi_startup(&apache_sapi_module);
php_apache_startup(&apache_sapi_module);
}
# if MODULE_MAGIC_NUMBER
>= 19980527
{
TSRMLS_FETCH();
if (PG(expose_php))
{ ap_add_version_component( "PHP/" PHP_VERSION);
}
}
# endif
}
|
該函式主要呼叫兩個函式:sapi_startup(&apache_sapi_module); php_apache_startup(&apache_sapi_module);
?1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
SAPI_API
void sapi_startup(sapi_module_struct *sf) {
sf->ini_entries
= NULL;
sapi_module
= *sf;
.................
sapi_globals_ctor(&sapi_globals);
................
virtual_cwd_startup(); /*
Could use shutdown to free the main cwd but it would just slow it down for CGI */
..................
reentrancy_startup();
}
|
sapi_startup建立一個 sapi_globals_struct結構體。sapi_globals_struct儲存了Apache請求的基本資訊,如伺服器資訊,Header,編碼等。sapi_startup執行完畢後再執行php_apache_startup。
?