Where is the entry point of any SAPI code?
CLI is a standalone application. Like any other application written in C, its entry point is a function main()(file sapi/cli/php_cli.c, line 1200):
int main(int argc, char *argv[])
CLI Windows, - main(), , - Windows GUI ( ), WinMain() ( sapi/cli/php_cli.c, 1198).
main() WinMain() . , , PHP_CLI_WIN32_NO_CONSOLE. sapi/cli/cli_win32.c, Windows GUI.
</Windows>
CGI . main() sapi/cgi/cgi_main.c, 1792.
, FPM main() sapi/fpm/fpm/fpm_main.c, 1570.
Apache2 - (.dll Windows, .so Unix- ). , - ( , / , ..). php_ap2_register_hook() sapi/apache2handler/sapi_apache2.c, 738.
( , Apache Apache documentation.)
php_handler(), HTTP-.
, SAPI ( main(), , -).
:
, PHP script?
php_execute_script() ; php.ini auto_prepend_file auto_append_file, ( , script, ) zend_execute_scripts(), .
php_execute_script() , SAPI CLI zend_execute_scripts().
zend_execute_scripts(), .
PHP ( OP- op_array, , ( op_array NULL), OP- , , , , .
- . zendparse(), Zend/zend_language_parser.c. zendparse() Zend/zend_language_parser.c Git; bison re2c, Zend/zend_language_parser.y Zend/zend_language_scanner.l Zend/zend_language_parser.c.
, , , .
script ( OP-) zend_execute(), Zend/zend_vm_execute.h. , , PHP script.
script (Zend/zend_vm_gen.php) zend_vm_def.h zend_vm_execute.skl zend_vm_execute.h zend_vm_opcodes.h.
zend_vm_def.h , OP-.
, PHP ?
PHP, , - . , PHP, ext/standard, , , ext .
C, PHP, PHP_FUNCTION(). , PHP strpos()
ext/standard/string.c, 1948. strchr() strstr() PHP_FALIAS() ext/standard/basic_functions.c 2833.
..