{"id":362401,"date":"2024-05-21T01:34:23","date_gmt":"2024-05-21T01:34:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=362401"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=362401","title":{"rendered":"<span>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f PHP \u043d\u0430 C++. \u0425\u0443\u043a\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ca0\/55b\/832\/ca055b832b02cdeed1f84d13895591f9.png\" width=\"350\" height=\"427\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ca0\/55b\/832\/ca055b832b02cdeed1f84d13895591f9.png\"\/><\/figure>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f PHP \u043d\u0430 C++. \u0425\u0443\u043a\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/h2>\n<p>PHP &#8212; \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f  \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f PHP  \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a C++. \u0412 \u044d\u0442\u043e\u0439  \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f PHP \u043d\u0430 C++ \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 php.<\/p>\n<h2>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h2>\n<p>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\n<p>\u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0438\u0437 php, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0445\u0443\u043a \u043d\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434, \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0435 <strong>hook_set_hook<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>hook_set_hook<\/strong> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430, callback \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, callback \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0432\u044b\u0439 callback \u2014 \u043f\u0440\u0438 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0432\u0442\u043e\u0440\u043e\u0439 callback \u2014  \u043f\u0440\u0438 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<h2>\u0428\u0430\u0433 1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 php \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e php, \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 php7+. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0443\u0442\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432, \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/php\/php-src.git cd php-src .\/buildconf --force .\/configure --enable-debug make sudo make install<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u043b\u0430\u0433 <code>--enable\u2011debug<\/code> \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a gdb<\/p>\n<h2>\u0428\u0430\u0433 2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 <strong>ext_skel.php<\/strong>, \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c\u0438. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0435 \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f hooks:<\/p>\n<pre><code class=\"bash\">cd \/path\/to\/your\/extension \/path\/to\/php-src\/ext\/ext_skel.php --ext=hooks --dir . cd hooks<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 hooks \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<p> config.m4<br \/> config.w32<br \/> hooks.c<br \/> hooks.stub.php<br \/> hooks_arginfo.h<br \/> php_hooks.h<br \/> tests<\/p>\n<\/div>\n<\/details>\n<h2>\u0428\u0430\u0433 3. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>ext_skel.php<\/strong> \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b config.m4 (config.w32 \u0434\u043b\u044f windows), \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0433\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u0441++, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0444\u0430\u0439\u043b hooks.c \u0432 hooks.cpp <\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 config.m4 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 dnl, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u0445 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0444\u0438\u0433:<\/p>\n<pre><code class=\"bash\">PHP_ARG_ENABLE([hooks],   [whether to enable hooks support],   [AS_HELP_STRING([--enable-hooks],     [Enable hooks support])],   [no])  if test \"$PHP_HOOKS\" != \"no\"; then   AC_DEFINE(HAVE_HOOKS, 1, [ Have hooks support ])   PHP_SUBST(HOOKS_SHARED_LIBADD)    dnl \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430   HOOKS_COMMON_FLAGS=\"-Wno-write-strings -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1\"    PHP_NEW_EXTENSION(hooks, , $ext_shared,,HOOKS_COMMON_FLAGS,cxx)    dnl \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 c++ c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u0441++17   PHP_REQUIRE_CXX()   PHP_CXX_COMPILE_STDCXX(17, mandatory, PHP_HOOKS_STDCXX)    PHP_HOOKS_CXX_FLAGS=\"$HOOKS_COMMON_FLAGS $PHP_HOOKS_STDCXX\"   PHP_ADD_SOURCES_X(PHP_EXT_DIR(hooks),  hooks.cpp, $PHP_HOOKS_CXX_FLAGS, shared_objects_hooks, yes) fi <\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u0434\u0430\u043b\u0435\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 phpize \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043a \u0441\u0431\u043e\u0440\u043a\u0435, \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e configure, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f make \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435:<\/p>\n<pre><code class=\"bash\"> phpize &amp;&amp; .\/configure &amp;&amp; make &amp;&amp; make test<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>===================================================================== TIME START 2023-12-06 12:47:11 ===================================================================== PASS Check if hooks is loaded [tests\/001.phpt] PASS test1() Basic test [tests\/002.phpt] PASS test2() Basic test [tests\/003.phpt] ===================================================================== TIME END 2023-12-06 12:47:11  ===================================================================== TEST RESULT SUMMARY --------------------------------------------------------------------- Exts skipped    :    0 Exts tested     :   26 ---------------------------------------------------------------------  Number of tests :    3                 3 Tests skipped   :    0 (  0.0%) -------- Tests warned    :    0 (  0.0%) (  0.0%) Tests failed    :    0 (  0.0%) (  0.0%) Tests passed    :    3 (100.0%) (100.0%) --------------------------------------------------------------------- Time taken      :    0 seconds =====================================================================<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u044b \u0438 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u0428\u0430\u0433 4. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 IDE<\/h2>\n<p>\u0412 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0439 \u041e\u0421 \u044f \u0434\u0430\u0432\u043d\u043e \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Windows, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 IDE \u0434\u043b\u044f C++ \u0443 \u043c\u0435\u043d\u044f CLion, \u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u043e\u0434 Linux \u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e WSL. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0439 \u0448\u0430\u0433 \u0431\u0443\u0434\u0435\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0432 IDE, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 CLion \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 CMake, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b CMakeLists.txt \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u043d \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b IDE \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 php \u0438 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<pre><code class=\"cmake\">cmake_minimum_required(VERSION 3.16) project(hooks CXX)  SET(CMAKE_CXX_STANDARD 17) SET(PHPCPP_PHP_PATH \"\/usr\/include\/php\/20210902\") #\u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439 \u043f\u0443\u0442\u044c  INCLUDE_DIRECTORIES(         \"${PHPCPP_PHP_PATH}\/\"         \"${PHPCPP_PHP_PATH}\/main\"         \"${PHPCPP_PHP_PATH}\/Zend\"         \"${PHPCPP_PHP_PATH}\/TSRM\"         \"${PHPCPP_PHP_PATH}\/ext\"         \"${PHPCPP_PHP_PATH}\/build\/main\"         \"${PHPCPP_PHP_PATH}\/build\/Zend\" )  add_library(hooks SHARED         config.h         hooks.cpp         php_hooks.h)<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043d\u0430\u0436\u0430\u0442\u044c &#171;Load CMake Project&#187;<\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 wsl, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043c\u0435\u043d\u044e IDE \u043e\u0442\u043a\u0440\u043e\u0435\u043c File -> Settings -> Build, Execution, Deployment -> Toolchains, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c WSL. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/755\/22c\/4b0\/75522c4b0e0e635e5324df188b34cf5f.png\" alt=\"WSL \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d, \u0432\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u044b\" title=\"WSL \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d, \u0432\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u044b\" width=\"2180\" height=\"1077\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/755\/22c\/4b0\/75522c4b0e0e635e5324df188b34cf5f.png\"\/><\/p>\n<div><figcaption>WSL \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d, \u0432\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0430\u043c\u0430 \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043d\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <u>CMake Application<\/u>, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e, \u0430 \u0447\u0435\u0440\u0435\u0437 <u>make<\/u>, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <u>Before launch<\/u> \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <u>Build<\/u> \u043d\u0430 <u>External tool &#8216;External Tools\/make&#8217;<\/u>.<br \/>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <u>Executable<\/u> \u043c\u044b \u0443\u043a\u0430\u0436\u0435\u043c \u043f\u0443\u0442\u044c \u0434\u043e <u>php<\/u>, \u0442.\u043a. \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u0435\u043d\u043d\u043e php \u0441\u043a\u0440\u0438\u043f\u0442\u044b.<br \/>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b php \u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0437\u0434\u0435\u0441\u044c \u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 <u>test.php<\/u> \u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u0430\u043d\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0439 \u0432\u043a\u0443\u0441, \u043a\u0430\u043a \u0432\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<pre><code> -n -c '\/path\/to\/hooks\/tmp-php.ini'  -d \"output_handler=\" -d \"open_basedir=\" -d \"disable_functions=\" -d \"output_buffering=Off\" -d \"error_reporting=32767\" -d \"display_errors=1\" -d \"display_startup_errors=1\" -d \"log_errors=0\" -d \"html_errors=0\" -d \"track_errors=0\" -d \"report_memleaks=1\" -d \"report_zend_debug=0\" -d \"docref_root=\" -d \"docref_ext=.html\" -d \"error_prepend_string=\" -d \"error_append_string=\" -d \"auto_prepend_file=\" -d \"auto_append_file=\" -d \"ignore_repeated_errors=0\" -d \"precision=14\" -d \"memory_limit=128M\" -d \"log_errors_max_len=0\" -d \"opcache.fast_shutdown=0\" -d \"opcache.file_update_protection=0\" -d \"opcache.revalidate_freq=0\" -d \"zend.assertions=1\" -d \"zend.exception_ignore_args=0\" -d \"extension_dir=\/path\/to\/hooks\/modules\/\" -d \"extension=hooks.so\" -d \"session.auto_start=0\" -d \"zlib.output_compression=Off\" -f \"\/path\/to\/hooks\/test.php\"  2>&amp;1 <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee4\/c68\/8f2\/ee4c688f20cc87ca7043358bc3c5cf34.png\" alt=\"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\" title=\"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\" width=\"1946\" height=\"1388\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ee4\/c68\/8f2\/ee4c688f20cc87ca7043358bc3c5cf34.png\"\/><\/p>\n<div><figcaption>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <u>test.php<\/u> \u0432 \u043a\u043e\u0440\u043d\u0435 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"php\">&lt;? echo extension_loaded('hooks') ? 'Extension loaded' : 'Extension NOT loaded';<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 (Shift+F10), \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c:<\/p>\n<pre><code>Extension loaded Process finished with exit code 0<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u043d\u043e\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0448\u0430\u0433\u0438<\/p>\n<h2>\u0428\u0430\u0433 5. \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441  Zend Engine<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 <u>hooks.cpp<\/u>, \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0438\u0437\u0443 \u0444\u0430\u0439\u043b\u0430, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <strong>zend_module_entry<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043c\u043e\u0434\u0443\u043b\u0435<\/p>\n<pre><code class=\"cpp\">zend_module_entry hooks_module_entry = { STANDARD_MODULE_HEADER,   \"hooks\",           \/\/ \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f ext_functions,     \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u0448\u0435\u043d\u0438\u044f nullptr,           \/\/ callback \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f nullptr,           \/\/ callback \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f PHP_RINIT(hooks),  \/\/ callback \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 nullptr,           \/\/ callback \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 PHP_MINFO(hooks),  \/\/ \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043c\u043e\u0434\u0443\u043b\u0435 PHP_HOOKS_VERSION, \/\/ \u0432\u0435\u0440\u0441\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f STANDARD_MODULE_PROPERTIES }; <\/code><\/pre>\n<p>\u0427\u0443\u0442\u044c \u0432\u044b\u0448\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u043a\u0440\u043e\u0441 <strong>PHP_MINFO_FUNCTION(<\/strong>hooks<strong>)<\/strong> \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>zm_info_hooks<\/em>, \u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 Zend Engine\u0443:<\/p>\n<pre><code class=\"cpp\">PHP_MINFO_FUNCTION(hooks){ php_info_print_table_start(); php_info_print_table_header(2, \"hooks support\", \"enabled\"); php_info_print_table_end(); }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0432 \u0432\u044b\u0432\u043e\u0434 <strong>phpinfo<\/strong> \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u0448\u0435\u043c \u0440\u0430c\u0448\u0438\u0440\u0435\u043d\u0438\u0438. <br \/>\u0415\u0449\u0435 \u0432\u044b\u0448\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f callback-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"cpp\">PHP_RINIT_FUNCTION(hooks){ #if defined(ZTS) &amp;&amp; defined(COMPILE_DL_HOOKS) ZEND_TSRMLS_CACHE_UPDATE(); #endif return SUCCESS; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0441\u043e\u0431\u0440\u0430\u043d \u043b\u0438 php \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 <strong>ZTS<\/strong> (zend thread safety) \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441 <strong>ZEND_TSRMLS_CACHE_UPDATE<\/strong>() \u044d\u0442\u043e\u0442 \u0432\u044b\u0437\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043a\u043e\u0433\u0434\u0430 php \u0441\u043e\u0431\u0440\u0430\u043d \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0435 \u0443\u0447\u0435\u0431\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 test1 \u0438 test2:<\/p>\n<pre><code class=\"cpp\">PHP_FUNCTION(test1){ ZEND_PARSE_PARAMETERS_NONE();  php_printf(\"The extension %s is loaded and working!\\r\\n\", \"hooks\"); }  PHP_FUNCTION(test2){ char *var = \"World\"; size_t var_len = sizeof(\"World\") - 1; zend_string *retval;  ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_STRING(var, var_len) ZEND_PARSE_PARAMETERS_END();  retval = strpprintf(0, \"Hello %s\", var);  RETURN_STR(retval); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <u>test1<\/u> \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <u>test2<\/u> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0435\u0441\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 &#171;Hello World&#187;, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 &#171;\u0421++&#187;, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 &#171;Hello C++&#187;.<br \/>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0436\u0435 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>hooks_arginfo.h<\/strong><\/p>\n<pre><code class=\"cpp\">ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test1, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO()  ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test2, 0, 0, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, str, IS_STRING, 0, \"\\\"\\\"\") ZEND_END_ARG_INFO()   ZEND_FUNCTION(test1); ZEND_FUNCTION(test2);   static const zend_function_entry ext_functions[] = { ZEND_FE(test1, arginfo_test1) ZEND_FE(test2, arginfo_test2) ZEND_FE_END }; <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <strong>hooks.stub.php<\/strong>, \u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438 <strong>hooks_arginfo.h<\/strong> \u043d\u0435\u043b\u044c\u0437\u044f, \u0438\u043d\u0430\u0447\u0435 \u0432\u0430\u0448\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0442\u0435\u0440\u0442\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<br \/>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0443 c <strong>hooks.stub.php<\/strong><\/p>\n<pre><code class=\"php\">&lt;?php  \/** @generate-class-entries *\/  function test1(): void {}  function test2(string $str = \"\"): string {} <\/code><\/pre>\n<p>\u0423\u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <u>test1<\/u> \u0438 <u>test2<\/u> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0432\u043e\u044e:<\/p>\n<pre><code class=\"php\">&lt;?php  \/** @generate-class-entries *\/  \/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0445\u0443\u043a\u043e\u0432 function hooks_set_hook(mixed ...$args): bool {}<\/code><\/pre>\n<p><sub>\u041d\u0435\u00a0\u0443\u0434\u0430\u043b\u044f\u0439\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 ` \/** <a class=\"mention\" href=\"\/users\/generate-class-entries\">@generate-class-entries<\/a> *\/`  <\/sub><\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>hooks_set_hook<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <strong>make,<\/strong> \u0444\u0430\u0439\u043b <strong>hooks_arginfo.h<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0437\u0430\u043d\u043e\u0432\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0444\u0430\u0439\u043b <strong>hooks.cpp<\/strong> \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438, \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <u>test1<\/u> \u0438 <u>test2<\/u>, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <strong>hooks_set_hook<\/strong>:<\/p>\n<pre><code class=\"cpp\">PHP_FUNCTION(hooks_set_hook){     php_printf(\"It works!\");     RETURN_TRUE; } <\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 test.php \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0437\u043e\u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">&lt;? hooks_set_hook();<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435:<\/p>\n<pre><code>It works!<\/code><\/pre>\n<h2>\u0428\u0430\u0433 6. \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e.<\/h2>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0445\u0443\u043a\u043e\u0432 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 <strong>hooks.stub.php<\/strong> \u0438 \u043e\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 php \u043a\u043e\u0434\u0435.<\/p>\n<pre><code class=\"cpp\">\/**  * \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.  * @param execute_data  * @param return_value  *\/ ZEND_NAMED_FUNCTION(my_hook) {    php_printf(\"my_hook\"); }<\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <strong>ZEND_NAMED_FUNCTION <\/strong>\u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e my_hook, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0432\u043e \u0447\u0442\u043e \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">void my_hook(zend_execute_data *execute_data, zval *return_value){     php_printf(\"my_hook\"); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>hooks_set_hook<\/strong>, \u0440\u0430\u043d\u0435\u0435 \u044f \u043f\u0438\u0441\u0430\u043b, \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0435 \u0432\u044b\u0437\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043e\u0431\u0440\u0430\u0437\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">&lt;? \/** * \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0445\u0443\u043a\u0430 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e * @param string function * @param callable before * @param callable after **\/ function hook_set_hook(string $function, callable $before, callable $after) : bool;  \/** * \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0445\u0443\u043a\u0430 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 * @param string class * @param string method * @param callable before * @param callable after **\/ function hook_set_hook(string $class, string $method, callable $before, callable $after) : bool; <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code class=\"cpp\">... \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0435\u043c\u0435\u043d\u0442\u043e\u0432 zend_string *function = nullptr; zend_class_entry *clazz = nullptr; zend_fcall_info before_fci = zend_fcall_info(); zend_fcall_info after_fci = zend_fcall_info(); zend_fcall_info_cache before_fcc = zend_fcall_info_cache(); zend_fcall_info_cache after_fcc = zend_fcall_info_cache();  \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432 \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), \"CSff\",                              &amp;clazz, &amp;function, &amp;before_fci, &amp;before_fcc, &amp;after_fci, &amp;after_fcc) != SUCCESS and     zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), \"Sff\",                              &amp;function, &amp;before_fci, &amp;before_fcc, &amp;after_fci, &amp;after_fcc) != SUCCESS         ) {     \/\/ \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0435 \u0442\u0435 \u0430\u0440\u0433\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0436\u0438\u0434\u0430\u043b\u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u0435\u0440\u043d\u0435\u043c false     zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, \"Invalid arguments\");     RETURN_BOOL(false); } ... <\/code><\/pre>\n<p>\u042f \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0437\u0434\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0443\u0442: <a href=\"https:\/\/github.com\/php\/php-src\/blob\/master\/docs\/parameter-parsing-api.md\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/php\/php-src\/blob\/master\/docs\/parameter-parsing-api.md<\/a><\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u0432\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"cpp\">#include \"ext\/spl\/spl_exceptions.h\" #include \"Zend\/zend_exceptions.h\"<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 <u>Fatal error: Uncaught InvalidArgumentException<\/u>.<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>hooks_set_hook<\/strong> \u0432\u0435\u0440\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0445\u0443\u043a \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <u>date<\/u>, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 <strong>test.php<\/strong> \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"php\">&lt;? $before = function ($args) {     echo \"before function called\\n\";     print_r($args); };  $after = function ($args) {     echo \"after function called\\n\";     print_r($args); };  hooks_set_hook('date', $before, $after);  echo date('Y-m-d');<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0434\u0430\u0442\u0443. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 date \u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u043d\u0430\u0448\u0438\u0445 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0439. <br \/>\u0412 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <strong>CG<\/strong> (compiler globals), \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 <strong>zend_class_entry<\/strong>. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 <strong>zend_hash_str_find_ptr<\/strong>:<\/p>\n<pre><code class=\"cpp\">... auto *original_function = static_cast&lt;zend_function *>(zend_hash_str_find_ptr(         clazz != nullptr ? &amp;clazz->function_table : CG(function_table), function->val,         function->len)); ...<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u0448\u043b\u0438 \u0438 \u044d\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f, \u0430 \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<pre><code class=\"cpp\">... if (original_function != nullptr) {     if (original_function->internal_function.type == ZEND_INTERNAL_FUNCTION) {     \/\/...   } } ...<\/code><\/pre>\n<p><strong>original_function<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 <strong>union _zend_function<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u043b\u0435 <strong>internal_function<\/strong> \u0442\u0438\u043f\u0430 <strong>zend_internal_function<\/strong>, \u0430 \u0432 \u043d\u0435\u043c \u0435\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c <strong>zif_handler<\/strong> <strong>handler<\/strong>, \u0435\u0433\u043e \u0442\u043e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>ZEND_NAMED_FUNCTION<\/strong>(my_hook) \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0432\u044b\u0448\u0435:<\/p>\n<pre><code class=\"cpp\">... original_function->internal_function.handler = my_hook; ...<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0434\u0430\u0442\u044b \u0443 \u043d\u0430\u0441 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442 &#171;my_hook&#187; \u0438 \u043e\u0448\u0438\u0431\u043a\u0430 <u>Fatal error: date(): Return value must be of type string, null returned in Unknown on line 0 <\/u> \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u043e \u043d\u0435 \u0435\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <u>date<\/u> \u0434\u043b\u044f \u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 <strong>ZEND_NAMED_FUNCTION<\/strong>(my_hook) <\/p>\n<p>\u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0435\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 <strong>php_hooks.h<\/strong><\/p>\n<pre><code class=\"cpp\">... struct hook_t {     std::string name;      zend_fcall_info before_fci{};     zend_fcall_info after_fci{};      zend_fcall_info_cache before_fcc{};     zend_fcall_info_cache after_fcc{};      zif_handler original_handler; };   ZEND_BEGIN_MODULE_GLOBALS(hooks)     std::map&lt;std::string, std::shared_ptr&lt;hook_t>> *originals; ZEND_END_MODULE_GLOBALS(hooks) ...<\/code><\/pre>\n<p>\u0412 \u043c\u0430\u043a\u0440\u043e\u0441\u0435 <strong>ZEND_MODULE_GLOBALS<\/strong> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f, \u043c\u0430\u043a\u0440\u043e\u0441 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0435\u0441\u043b\u0438 php \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 php-fpm, \u043f\u043e\u0434\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0436\u0438\u0437\u043d\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043d\u044f\u0442\u0438\u044f \u0445\u0443\u043a\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 <em>handler<\/em>, \u043b\u0438\u0431\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 <strong>PHP_RSHUTDOWN<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u0435 <strong>ZEND_MODULE_GLOBALS<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0435 <em>hooks.cpp,<\/em> \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <\/p>\n<pre><code>ZEND_DECLARE_MODULE_GLOBALS(hooks)<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 callback <strong>PHP_MINIT_FUNCTION<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043c\u043e\u0434\u0443\u043b\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <strong>hooks.cpp<\/strong><\/p>\n<pre><code class=\"cpp\">... static void php_init_globals(zend_hooks_globals *ng) {     ng->originals = new std::map&lt;std::string, std::shared_ptr&lt;hook_t>>(); }  PHP_MINIT_FUNCTION (hooks) {     ZEND_INIT_MODULE_GLOBALS(hooks, php_init_globals, null);     return SUCCESS; } ...<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <strong>zend_module_entry<\/strong>, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <strong>PHP_MINIT<\/strong>(hooks).<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u0435\u0440\u0435\u0437 <strong>hooks_globals<\/strong>, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>hooks_set_hook<\/strong> \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"cpp\">PHP_FUNCTION (hooks_set_hook) {     \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0435\u043c\u0435\u043d\u0442\u043e\u0432     zend_string *function = nullptr;     zend_class_entry *clazz = nullptr;     zend_fcall_info before_fci = zend_fcall_info();     zend_fcall_info after_fci = zend_fcall_info();     zend_fcall_info_cache before_fcc = zend_fcall_info_cache();     zend_fcall_info_cache after_fcc = zend_fcall_info_cache();      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432 \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432     if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), \"CSff\",                                  &amp;clazz, &amp;function, &amp;before_fci, &amp;before_fcc, &amp;after_fci, &amp;after_fcc) != SUCCESS and         zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), \"Sff\",                                  &amp;function, &amp;before_fci, &amp;before_fcc, &amp;after_fci, &amp;after_fcc) != SUCCESS             ) {         \/\/ \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0435 \u0442\u0435 \u0430\u0440\u0433\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0436\u0438\u0434\u0430\u043b\u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u0435\u0440\u043d\u0435\u043c false         zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, \"Invalid arguments\");         RETURN_FALSE;     }      \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430     auto *original_function = static_cast&lt;zend_function *>(zend_hash_str_find_ptr(             clazz != nullptr ? &amp;clazz->function_table : CG(function_table), function->val,             function->len));     \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e     if (original_function != nullptr) {         if (original_function->internal_function.type == ZEND_INTERNAL_FUNCTION) {             \/\/ \u0421\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447 \u0434\u043b\u044f std::map             std::string key;             if (clazz) {                 key.append(clazz->name->val);                 key.append(\"::\");             }             key.append(function->val);              \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u043b\u0438 \u043c\u044b \u0445\u0443\u043a \u0440\u0430\u043d\u0435\u0435             auto original_it = hooks_globals.originals->find(key);             if (original_it == hooks_globals.originals->end()) {                 \/\/\u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0443\u043b\u044f                 auto hook = std::make_shared&lt;hook_t>();                 hook->name = key;                 hook->before_fci = before_fci;                 hook->after_fci = after_fci;                  hook->before_fcc = before_fcc;                 hook->after_fcc = after_fcc;                 hook->original_handler = original_function->internal_function.handler;                 hooks_globals.originals->insert(std::pair&lt;std::string, std::shared_ptr&lt;hook_t>>(key, std::move(hook)));                 original_function->internal_function.handler = my_hook;                 RETURN_TRUE;             }         }     }     RETURN_FALSE; }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0445\u0443\u043a\u043e\u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e.<\/p>\n<h2>\u0428\u0430\u0433 7. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f callback \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/h2>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>ZEND_NAMED_FUNCTION<\/strong>(my_hook) \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0432 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 &#8212; <strong>zend_execute_data<\/strong> *<strong>execute_data<\/strong> \u0438 <strong>zval<\/strong> *<strong>return_value<\/strong>. \u041f\u0435\u0440\u0432\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. <br \/>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0435\u0435 \u0441\u0440\u0435\u0434\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0445\u0443\u043a\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">... \/\/ \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 auto function_name = execute_data->func->internal_function.function_name; std::string key; \/\/ \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c this \u0442\u043e \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 if (getThis() != nullptr) {     key.append(execute_data->func->internal_function.scope->name->val);     key.append(\"::\"); } key.append(function_name->val); \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u043a\u043b\u044e\u0447 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443. auto hook_info = hooks_globals.originals->find(key); if (hook_info == hooks_globals.originals->end()) {     return; } ...<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"cpp\">... hook_info->second->original_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); ...<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432\u0435\u0440\u043d\u043e \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0434\u0430\u0442\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <u>date<\/u>. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u043d\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438\u043c\u044f \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0432\u0441\u0435 \u0435\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<pre><code class=\"cpp\">... auto hook_info = hook_info_it->second;  \/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0438 name \u0438 args HashTable *handler_args_array; ALLOC_HASHTABLE(handler_args_array); zend_hash_init(handler_args_array, 0, NULL, ZVAL_PTR_DTOR, 0);  \/\/\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 zval handler_args_zval[2]; ZVAL_ARR(&amp;handler_args_zval[0], handler_args_array);  \/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 HashTable *hooked_args_array; ALLOC_HASHTABLE(hooked_args_array); zend_hash_init(hooked_args_array, 0, NULL, ZVAL_PTR_DTOR, 0);  zval hooked_args_zval; ZVAL_ARR(&amp;hooked_args_zval, hooked_args_array);  \/\/ \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043e\u043f\u0438\u044e int arg_count = ZEND_CALL_NUM_ARGS(execute_data); for (int i = 1; i &lt;= arg_count; i++) {     zend_hash_next_index_insert(hooked_args_array, ZEND_CALL_ARG(execute_data, i)); } \/\/ \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 handler_args_array zval hook_name; ZVAL_STRING(&amp;hook_name, key.c_str()); zend_hash_str_add(handler_args_array, \"name\", 4, &amp;hook_name); zend_hash_str_add(handler_args_array, \"args\", 4, &amp;hooked_args_zval);  \/\/ \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0432\u044b\u0437\u043e\u0432 \u043f\u0435\u0440\u0432\u043e\u0439 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 hook_info->before_fci.params = handler_args_zval; hook_info->before_fci.param_count = 2; \/\/ \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 zval before_ret; hook_info->before_fci.retval = &amp;before_ret;  zend_call_function(&amp;hook_info->before_fci, &amp;hook_info->before_fcc); ...<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c <u>date<\/u> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u043d\u0430\u0448 callback. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u043e \u0437\u0430 \u043c\u0430\u043b\u044b\u043c, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0435. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0435\u0433\u043e.<\/p>\n<pre><code class=\"cpp\">... \/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 if (Z_TYPE_P(return_value) != IS_NULL) {     zend_hash_str_add(handler_args_array, \"result\", 6, return_value); } \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0435\u0433\u043e auto exception = EG(exception); if (exception != nullptr) {     zval exception_zval;     ZVAL_OBJ(&amp;exception_zval, exception);     zend_hash_str_add(handler_args_array, \"exception\", 9, &amp;exception_zval);     zend_exception_save(); }  \/\/ \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0432\u044b\u0437\u043e\u0432 \u0432\u0442\u043e\u0440\u043e\u0439 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 hook_info->after_fci.params = handler_args_zval; hook_info->after_fci.param_count = 2; \/\/ \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 zval after_ret; hook_info->after_fci.retval = &amp;after_ret;  zend_call_function(&amp;hook_info->after_fci, &amp;hook_info->after_fcc);  \/\/ \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 if (exception != nullptr) {     zend_exception_restore(); }  \/\/\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b zend_hash_destroy(handler_args_array); FREE_HASHTABLE(handler_args_array); ...<\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 <em>zend_exception_save<\/em> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0430\u0432\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0442\u043e\u0440\u043e\u0433\u043e callback, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>zend_exception_restore.<\/em><\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0438 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a, \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0434\u0432\u0443\u0445 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f php \u043d\u0430 \u0441++ \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430. \u041e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 github, \u0441\u0441\u044b\u043b\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h2>\u0428\u0430\u0433 8. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f<\/h2>\n<p>\u041c\u044b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <em>date<\/em>, \u043d\u043e \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043c\u0435\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0411\u0414 SQLite:<\/p>\n<pre><code class=\"php\">&lt;? $before = function ($args) {     echo \"before function called\\n\";     print_r($args); };  $after = function ($args, $_this = null) {     echo \"after function called\\n\";     print_r($args); };  hooks_set_hook('PDO', '__construct', $before, $after);   try {     \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 SQLite     $pdo = new PDO('sqlite:\/database.db'); } catch (Exception $e) {     echo 'Connection failed: ' . $e->getMessage(); };<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>before function called Array (     [name] => PDO::__construct     [args] => Array         (             [0] => sqlite:\/database.db         )  ) after function called Array (     [name] => PDO::__construct     [args] => Array         (             [0] => sqlite:\/database.db         )      [exception] => PDOException Object         (             [message:protected] => SQLSTATE[HY000] [14] unable to open database file             [string:Exception:private] =>             [code:protected] => 14             [file:protected] => \/mnt\/c\/Users\/artuk\/Desktop\/hooks2\/test.php             [line:protected] => 17             [trace:Exception:private] => Array                 (                     [0] => Array                         (                             [file] => \/mnt\/c\/Users\/artuk\/Desktop\/hooks2\/test.php                             [line] => 17                             [function] => __construct                             [class] => PDO                             [type] => ->                             [args] => Array                                 (                                     [0] => sqlite:\/database.db                                 )                          )                  )              [previous:Exception:private] =>             [errorInfo] => Array                 (                     [0] => HY000                     [1] => 14                     [2] => unable to open database file                 )          )  ) Connection failed: SQLSTATE[HY000] [14] unable to open database file Process finished with exit code 0 <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u043e\u0441\u044c. \u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438\u043b\u0438 \u0441\u0431\u043e\u0440\u0430 \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0438\u0445 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c. \u0422\u0430\u043a\u0436\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u043d\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 \u0441\u0432\u044f\u0436\u0438\u0442\u0435\u0441\u044c \u0441\u043e \u043c\u043d\u043e\u0439.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f  PHP \u043d\u0430 C++. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043c\u044b  \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0448\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0448\u0430\u0433\u0438 \u043f\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0443\u043a\u043e\u0432 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f  callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041c\u044b \u043f\u043e\u043a\u0440\u044b\u043b\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043e\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0445\u0443\u043a\u043e\u0432 \u0432\u043e  \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 PHP-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438  \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u0430.<\/p>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<p><a href=\"https:\/\/github.com\/ArtUkrainskiy\/hooks\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/ArtUkrainskiy\/hooks<\/a><\/p>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<\/p>\n<p><a href=\"https:\/\/github.com\/php\/php-src\/\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/php\/php-src\/<\/a> &#8212; \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 php<\/p>\n<p><a href=\"https:\/\/www.phpinternalsbook.com\/\" rel=\"noopener noreferrer nofollow\">https:\/\/www.phpinternalsbook.com\/<\/a> &#8212; \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u0445\u043e\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/779344\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u041e \u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">52.94% <\/span><span class=\"tm-article-poll__answer-label\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e Zend Engine, zval \u0438 api \u0434\u0432\u0438\u0436\u043a\u0430 php<\/span><span class=\"tm-article-poll__answer-votes\">9<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 52.94%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">76.47% <\/span><span class=\"tm-article-poll__answer-label\">\u0420\u0430\u043d\u0442\u0430\u0439\u043c \u044f\u0437\u044b\u043a\u0430, \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430, \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/span><span class=\"tm-article-poll__answer-votes\">13<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 76.47%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">58.82% <\/span><span class=\"tm-article-poll__answer-label\">\u0424\u0438\u0447\u0438 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0438 \u0438\u0445 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e<\/span><span class=\"tm-article-poll__answer-votes\">10<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 58.82%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">0% <\/span><span class=\"tm-article-poll__answer-label\">\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c<\/span><span class=\"tm-article-poll__answer-votes\">0<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 0%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 17 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.   \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 4 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/779344\/\"> https:\/\/habr.com\/ru\/articles\/779344\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><\/figure>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f PHP \u043d\u0430 C++. \u0425\u0443\u043a\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/h2>\n<p>PHP &#8212; \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f  \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f PHP  \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a C++. \u0412 \u044d\u0442\u043e\u0439  \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f PHP \u043d\u0430 C++ \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 php.<\/p>\n<h2>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h2>\n<p>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\n<p>\u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0438\u0437 php, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0445\u0443\u043a \u043d\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434, \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0435 <strong>hook_set_hook<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>hook_set_hook<\/strong> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430, callback \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, callback \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0432\u044b\u0439 callback \u2014 \u043f\u0440\u0438 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0432\u0442\u043e\u0440\u043e\u0439 callback \u2014  \u043f\u0440\u0438 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<h2>\u0428\u0430\u0433 1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 php \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e php, \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 php7+. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0443\u0442\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432, \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/php\/php-src.git cd php-src .\/buildconf --force .\/configure --enable-debug make sudo make install<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u043b\u0430\u0433 <code>--enable\u2011debug<\/code> \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a gdb<\/p>\n<h2>\u0428\u0430\u0433 2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 <strong>ext_skel.php<\/strong>, \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c\u0438. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0435 \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f hooks:<\/p>\n<pre><code class=\"bash\">cd \/path\/to\/your\/extension \/path\/to\/php-src\/ext\/ext_skel.php --ext=hooks --dir . cd hooks<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 hooks \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<p> config.m4<br \/> config.w32<br \/> hooks.c<br \/> hooks.stub.php<br \/> hooks_arginfo.h<br \/> php_hooks.h<br \/> tests<\/p>\n<\/div>\n<\/details>\n<h2>\u0428\u0430\u0433 3. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>ext_skel.php<\/strong> \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b config.m4 (config.w32 \u0434\u043b\u044f windows), \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0433\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u0441++, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0444\u0430\u0439\u043b hooks.c \u0432 hooks.cpp <\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 config.m4 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 dnl, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u0445 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0444\u0438\u0433:<\/p>\n<pre><code class=\"bash\">PHP_ARG_ENABLE([hooks],   [whether to enable hooks support],   [AS_HELP_STRING([--enable-hooks],     [Enable hooks support])],   [no])  if test \"$PHP_HOOKS\" != \"no\"; then   AC_DEFINE(HAVE_HOOKS, 1, [ Have hooks support ])   PHP_SUBST(HOOKS_SHARED_LIBADD)    dnl \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430   HOOKS_COMMON_FLAGS=\"-Wno-write-strings -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1\"    PHP_NEW_EXTENSION(hooks, , $ext_shared,,HOOKS_COMMON_FLAGS,cxx)    dnl \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 c++ c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u0441++17   PHP_REQUIRE_CXX()   PHP_CXX_COMPILE_STDCXX(17, mandatory, PHP_HOOKS_STDCXX)    PHP_HOOKS_CXX_FLAGS=\"$HOOKS_COMMON_FLAGS $PHP_HOOKS_STDCXX\"   PHP_ADD_SOURCES_X(PHP_EXT_DIR(hooks),  hooks.cpp, $PHP_HOOKS_CXX_FLAGS, shared_objects_hooks, yes) fi <\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u0434\u0430\u043b\u0435\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 phpize \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043a \u0441\u0431\u043e\u0440\u043a\u0435, \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e configure, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f make \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435:<\/p>\n<pre><code class=\"bash\"> phpize &amp;&amp; .\/configure &amp;&amp; make &amp;&amp; make test<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>===================================================================== TIME START 2023-12-06 12:47:11 ===================================================================== PASS Check if hooks is loaded [tests\/001.phpt] PASS test1() Basic test [tests\/002.phpt] PASS test2() Basic test [tests\/003.phpt] ===================================================================== TIME END 2023-12-06 12:47:11  ===================================================================== TEST RESULT SUMMARY --------------------------------------------------------------------- Exts skipped    :    0 Exts tested     :   26 ---------------------------------------------------------------------  Number of tests :    3                 3 Tests skipped   :    0 (  0.0%) -------- Tests warned    :    0 (  0.0%) (  0.0%) Tests failed    :    0 (  0.0%) (  0.0%) Tests passed    :    3 (100.0%) (100.0%) --------------------------------------------------------------------- Time taken      :    0 seconds =====================================================================<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u044b \u0438 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u0428\u0430\u0433 4. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 IDE<\/h2>\n<p>\u0412 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0439 \u041e\u0421 \u044f \u0434\u0430\u0432\u043d\u043e \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Windows, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 IDE \u0434\u043b\u044f C++ \u0443 \u043c\u0435\u043d\u044f CLion, \u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u043e\u0434 Linux \u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e WSL. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0439 \u0448\u0430\u0433 \u0431\u0443\u0434\u0435\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0432 IDE, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 CLion \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 CMake, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b CMakeLists.txt \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u043d \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b IDE \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 php \u0438 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<pre><code class=\"cmake\">cmake_minimum_required(VERSION 3.16) project(hooks CXX)  SET(CMAKE_CXX_STANDARD 17) SET(PHPCPP_PHP_PATH \"\/usr\/include\/php\/20210902\") #\u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439 \u043f\u0443\u0442\u044c  INCLUDE_DIRECTORIES(         \"${PHPCPP_PHP_PATH}\/\"         \"${PHPCPP_PHP_PATH}\/main\"         \"${PHPCPP_PHP_PATH}\/Zend\"         \"${PHPCPP_PHP_PATH}\/TSRM\"         \"${PHPCPP_PHP_PATH}\/ext\"         \"${PHPCPP_PHP_PATH}\/build\/main\"         \"${PHPCPP_PHP_PATH}\/build\/Zend\" )  add_library(hooks SHARED         config.h         hooks.cpp         php_hooks.h)<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043d\u0430\u0436\u0430\u0442\u044c &#171;Load CMake Project&#187;<\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 wsl, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043c\u0435\u043d\u044e IDE \u043e\u0442\u043a\u0440\u043e\u0435\u043c File -> Settings -> Build, Execution, Deployment -> Toolchains, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c WSL. <\/p>\n<figure class=\"full-width\">\n<div><figcaption>WSL \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d, \u0432\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0430\u043c\u0430 \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043d\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <u>CMake Application<\/u>, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e, \u0430 \u0447\u0435\u0440\u0435\u0437 <u>make<\/u>, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <u>Before launch<\/u> \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <u>Build<\/u> \u043d\u0430 <u>External tool &#8216;External Tools\/make&#8217;<\/u>.<br \/>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <u>Executable<\/u> \u043c\u044b \u0443\u043a\u0430\u0436\u0435\u043c \u043f\u0443\u0442\u044c \u0434\u043e <u>php<\/u>, \u0442.\u043a. \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u0435\u043d\u043d\u043e php \u0441\u043a\u0440\u0438\u043f\u0442\u044b.<br \/>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b php \u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0437\u0434\u0435\u0441\u044c \u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 <u>test.php<\/u> \u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u0430\u043d\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0439 \u0432\u043a\u0443\u0441, \u043a\u0430\u043a \u0432\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<pre><code> -n -c '\/path\/to\/hooks\/tmp-php.ini'  -d \"output_handler=\" -d \"open_basedir=\" -d \"disable_functions=\" -d \"output_buffering=Off\" -d \"error_reporting=32767\" -d \"display_errors=1\" -d \"display_startup_errors=1\" -d \"log_errors=0\" -d \"html_errors=0\" -d \"track_errors=0\" -d \"report_memleaks=1\" -d \"report_zend_debug=0\" -d \"docref_root=\" -d \"docref_ext=.html\" -d \"error_prepend_string=\" -d \"error_append_string=\" -d \"auto_prepend_file=\" -d \"auto_append_file=\" -d \"ignore_repeated_errors=0\" -d \"precision=14\" -d \"memory_limit=128M\" -d \"log_errors_max_len=0\" -d \"opcache.fast_shutdown=0\" -d \"opcache.file_update_protection=0\" -d \"opcache.revalidate_freq=0\" -d \"zend.assertions=1\" -d \"zend.exception_ignore_args=0\" -d \"extension_dir=\/path\/to\/hooks\/modules\/\" -d \"extension=hooks.so\" -d \"session.auto_start=0\" -d \"zlib.output_compression=Off\" -f \"\/path\/to\/hooks\/test.php\"  2>&amp;1 <\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <u>test.php<\/u> \u0432 \u043a\u043e\u0440\u043d\u0435 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"php\">&lt;? echo extension_loaded('hooks') ? 'Extension loaded' : 'Extension NOT loaded';<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 (Shift+F10), \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c:<\/p>\n<pre><code>Extension loaded Process finished with exit code 0<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u043d\u043e\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0448\u0430\u0433\u0438<\/p>\n<h2>\u0428\u0430\u0433 5. \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441  Zend Engine<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 <u>hooks.cpp<\/u>, \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0438\u0437\u0443 \u0444\u0430\u0439\u043b\u0430, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <strong>zend_module_entry<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043c\u043e\u0434\u0443\u043b\u0435<\/p>\n<pre><code class=\"cpp\">zend_module_entry hooks_module_entry = { STANDARD_MODULE_HEADER,   \"hooks\",           \/\/ \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f ext_functions,     \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u0448\u0435\u043d\u0438\u044f nullptr,           \/\/ callback \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f nullptr,           \/\/ callback \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f PHP_RINIT(hooks),  \/\/ callback \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 nullptr,           \/\/ callback \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 PHP_MINFO(hooks),  \/\/ \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043c\u043e\u0434\u0443\u043b\u0435 PHP_HOOKS_VERSION, \/\/ \u0432\u0435\u0440\u0441\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f STANDARD_MODULE_PROPERTIES }; <\/code><\/pre>\n<p>\u0427\u0443\u0442\u044c \u0432\u044b\u0448\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u043a\u0440\u043e\u0441 <strong>PHP_MINFO_FUNCTION(<\/strong>hooks<strong>)<\/strong> \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>zm_info_hooks<\/em>, \u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 Zend Engine\u0443:<\/p>\n<pre><code class=\"cpp\">PHP_MINFO_FUNCTION(hooks){ php_info_print_table_start(); php_info_print_table_header(2, \"hooks support\", \"enabled\"); php_info_print_table_end(); }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0432 \u0432\u044b\u0432\u043e\u0434 <strong>phpinfo<\/strong> \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u0448\u0435\u043c \u0440\u0430c\u0448\u0438\u0440\u0435\u043d\u0438\u0438. <br \/>\u0415\u0449\u0435 \u0432\u044b\u0448\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f callback-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"cpp\">PHP_RINIT_FUNCTION(hooks){ #if defined(ZTS) &amp;&amp; defined(COMPILE_DL_HOOKS) ZEND_TSRMLS_CACHE_UPDATE(); #endif return SUCCESS; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0441\u043e\u0431\u0440\u0430\u043d \u043b\u0438 php \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 <strong>ZTS<\/strong> (zend thread safety) \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441 <strong>ZEND_TSRMLS_CACHE_UPDATE<\/strong>() \u044d\u0442\u043e\u0442 \u0432\u044b\u0437\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043a\u043e\u0433\u0434\u0430 php \u0441\u043e\u0431\u0440\u0430\u043d \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0435 \u0443\u0447\u0435\u0431\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 test1 \u0438 test2:<\/p>\n<pre><code class=\"cpp\">PHP_FUNCTION(test1){<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-362401","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=362401"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362401\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=362401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=362401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=362401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}