php_module_startup执行完成后,接下来就执行do_cli, php的主要执行逻辑都在这里。
zend_first_try {
exit_status = do_cli(argc, argv);
} zend_end_try();
do_cli已经来就是检查参数的2个大循环,这里不讨论这些参数,我们以最简单的启动方式来讲:php xxx.php
一、打开脚本文件
if (script_file)
{
if (cli_seek_file_begin(&file_handle, script_file, &lineno) != SUCCESS)
{
goto err;
}
else
{
char real_path[MAXPATHLEN];
if (VCWD_REALPATH(script_file, real_path))
{
translated_path = strdup(real_path);
}
script_filename = script_file;
}
}
二、php_request_startup 启动请求
这个函数内容比较多,接下来就讲这个
三、zend_interned_strings_activate 初始化本次请求的字符串表
ZEND_API void zend_interned_strings_activate(void)
{
zend_init_interned_strings_ht(&CG(interned_strings), 0);
}
四、php_output_activate 初始化输出结构