搜索
首页php教程php手册PHP内核两大流程之启动PHP的核心代码段

PHP内核两大流程之启动PHP的核心代码段

Step 1: Start the sapi

extern zend_module_entry php_apache_module;

static int php_apache2_startup(sapi_module_struct *sapi_module)
{
        if (php_module_startup(sapi_module, &php_apache_module, 1)==FAILURE) {
                return FAILURE;
        }
        return SUCCESS;
}

Step 2: Start the php

int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules)
{
        zend_utility_functions zuf;
        zend_utility_values zuv;

	.....

	sapi_module = *sf;

	php_output_startup();

        zuf.error_function = php_error_cb;
        zuf.printf_function = php_printf;
        zuf.write_function = php_output_wrapper;
        zuf.fopen_function = php_fopen_wrapper_for_zend;
        zuf.message_handler = php_message_handler_for_zend;
        zuf.block_interruptions = sapi_module.block_interruptions;
        zuf.unblock_interruptions = sapi_module.unblock_interruptions;
        zuf.get_configuration_directive = php_get_configuration_directive_for_zend;
        zuf.ticks_function = php_run_ticks;
        zuf.on_timeout = php_on_timeout;
        zuf.stream_open_function = php_stream_open_for_zend;
        zuf.vspprintf_function = vspprintf;
        zuf.getenv_function = sapi_getenv;
        zuf.resolve_path_function = php_resolve_path_for_zend;
        zend_startup(&zuf, NULL TSRMLS_CC);

	......

	gc_globals_ctor(TSRMLS_C);

	......

        /* Register PHP core ini entries */
        REGISTER_INI_ENTRIES();

        /* Register Zend ini entries */
        zend_register_standard_ini_entries(TSRMLS_C);

        /* Disable realpath cache if an open_basedir is set */
        if (PG(open_basedir) && *PG(open_basedir)) {
                CWDG(realpath_cache_size_limit) = 0;
        }

        /* initialize stream wrappers registry
         * (this uses configuration parameters from php.ini)
         */
        if (php_init_stream_wrappers(module_number TSRMLS_CC) == FAILURE)       {
                php_printf("PHP:  Unable to initialize stream url wrappers.\n");
                return FAILURE;
        }

        /* startup extensions staticly compiled in */
        if (php_register_internal_extensions_func(TSRMLS_C) == FAILURE) {
                php_printf("Unable to start builtin modules\n");
                return FAILURE;
        }

        /* start additional PHP extensions */
        php_register_extensions_bc(additional_modules, num_additional_modules TSRMLS_CC);

        /* load and startup extensions compiled as shared objects (aka DLLs)
           as requested by php.ini entries
           theese are loaded after initialization of internal extensions
           as extensions *might* rely on things from ext/standard
           which is always an internal extension and to be initialized
           ahead of all other internals
         */
        php_ini_register_extensions(TSRMLS_C);
        zend_startup_modules(TSRMLS_C);

        /* start Zend extensions */
        zend_startup_extensions();

	.....
}

int zend_startup
(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC) /* {{{ */
{
        zend_compiler_globals *compiler_globals;
        zend_executor_globals *executor_globals;
	
	......

        zend_compile_file = compile_file;
        zend_execute_ex = execute_ex;
        zend_execute_internal = NULL;

        zend_init_opcodes_handlers();
	
	......
}

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能