{"id":47615,"date":"2024-12-02T08:52:48","date_gmt":"2024-12-02T00:52:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47615\/"},"modified":"2024-12-02T08:52:48","modified_gmt":"2024-12-02T00:52:48","slug":"php-%e5%87%bd%e6%95%b0%e5%9c%a8-c-%e6%89%a9%e5%b1%95%e4%b8%ad%e7%9a%84%e8%b0%83%e7%94%a8%e6%98%af%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47615\/","title":{"rendered":"PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f<\/h1>\n<p>\u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f\u300b<\/span>\uff0c\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u77e5\u8bc6\u70b9\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u65e0\u8bba\u4f60\u662f\u5c0f\u767d\u8fd8\u662f\u8001\u624b\uff0c\u90fd\u9002\u5408\u770b\u4e00\u770b\u54e6~\u6709\u597d\u7684\u5efa\u8bae\u4e5f\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u82e5\u662f\u770b\u5b8c\u6709\u6240\u6536\u83b7\uff0c\u4e5f\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u70b9\u8d5e\u652f\u6301\u5440\uff01\u4e00\u8d77\u52a0\u6cb9\u5b66\u4e60~<\/p>\n<p>PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u901a\u8fc7\u51fd\u6570\u8868\u5b9e\u73b0\u3002\u51fd\u6570\u8868\u662f\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\uff0c\u5b58\u50a8 PHP \u51fd\u6570\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u6307\u5411 C \u51fd\u6570\u7684\u6307\u9488\u3002\u5f53 PHP \u9047\u5230\u6269\u5c55\u51fd\u6570\u65f6\uff0c\u5b83\u4f1a\u5728\u51fd\u6570\u8868\u4e2d\u67e5\u627e\u8be5\u51fd\u6570\uff0c\u5e76\u8c03\u7528\u6307\u5411\u7684 C \u51fd\u6570\u3002\u4f8b\u5982\uff0c\u8981\u5b9a\u4e49\u5e76\u6ce8\u518c &#8220;my_function&#8221; \u51fd\u6570\uff0c\u9700\u521b\u5efa\u51fd\u6570\u8868\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u6269\u5c55\u6a21\u5757\u4e2d\uff0c\u7136\u540e\u5728 PHP \u4ee3\u7801\u4e2d\u5f15\u7528\u8be5\u51fd\u6570\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729925802671c92aa97245.jpg\" class=\"aligncenter\" title=\"PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f\u63d2\u56fe\" alt=\"PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684<\/strong><\/p>\n<p>PHP \u662f\u7531 C \u7f16\u5199\u7684\uff0c\u56e0\u6b64 C \u6269\u5c55\u672c\u8d28\u4e0a\u662f PHP \u89e3\u91ca\u5668\u548c C \u4ee3\u7801\u4e4b\u95f4\u7684\u63a5\u53e3\u3002\u5f53 PHP \u6269\u5c55\u4e2d\u521b\u5efa\u51fd\u6570\u65f6\uff0c\u9700\u8981\u4e00\u4e2a\u673a\u5236\u6765\u5c06\u8fd9\u4e9b\u51fd\u6570\u4e0e PHP \u89e3\u91ca\u5668\u8fde\u63a5\u8d77\u6765\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fd9\u4e2a\u673a\u5236\uff0c\u5e76\u901a\u8fc7\u5b9e\u6218\u6848\u4f8b\u8bf4\u660e\u5176\u5de5\u4f5c\u539f\u7406\u3002<\/p>\n<p><strong>\u65b9\u6cd5<\/strong><\/p>\n<p>PHP \u4f7f\u7528\u4e00\u4e2a\u540d\u4e3a Function Table\uff08\u51fd\u6570\u8868\uff09\u7684\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u6709\u5173 PHP \u51fd\u6570\u7684\u4fe1\u606f\u3002\u6bcf\u4e2a\u6269\u5c55\u90fd\u53ef\u4ee5\u6ce8\u518c\u81ea\u5df1\u7684\u51fd\u6570\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6307\u5411 C \u51fd\u6570\u7684\u6307\u9488\u3002\u5f53 PHP \u9047\u5230\u9700\u8981\u6267\u884c\u7684\u6269\u5c55\u51fd\u6570\u65f6\uff0c\u5b83\u4f1a\u5728\u51fd\u6570\u8868\u4e2d\u67e5\u627e\u8be5\u51fd\u6570\uff0c\u7136\u540e\u8c03\u7528\u6307\u5411\u7684 C \u51fd\u6570\u3002<\/p>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5728 &#8220;my_extension&#8221; C \u6269\u5c55\u4e2d\u521b\u5efa\u548c\u6ce8\u518c PHP \u51fd\u6570\u7684\u7b80\u5355\u793a\u4f8b\uff1a<\/p>\n<pre>#include \"php.h\"\n\n\/\/ \u5b9a\u4e49\u4e00\u4e2a PHP \u51fd\u6570\nPHP_FUNCTION(my_function)\n{\n    \/\/ \u51fd\u6570\u5b9e\u73b0\n}\n\n\/\/ \u6ce8\u518c\u51fd\u6570\nzend_function_entry my_functions[] = {\n    PHP_FE(my_function, NULL) \/\/ NULL \u8868\u793a\u6ca1\u6709\u53c2\u6570\n    {NULL, NULL, NULL} \/\/ \u54e8\u5175\uff0c\u8868\u793a\u51fd\u6570\u8868\u7ed3\u675f\n};\n\nzend_module_entry my_extension = {\n    STANDARD_MODULE_HEADER,\n    NULL,                        \/\/ Start_module\n    NULL,                        \/\/ End_module\n    NULL,                        \/\/ Activate_function\n    NULL,                        \/\/ Deactivate_function\n    NULL,                        \/\/ Request_startup_function\n    NULL,                        \/\/ Request_shutdown_function\n    NULL,                        \/\/ Rinit_function\n    NULL,                        \/\/ Rshutdown_function\n    NULL,                        \/\/ Minit_function\n    NULL,                        \/\/ Mshutdown_function\n    my_functions,                \/\/ Functions\n    NULL,                        \/\/ Module dependencies\n    NULL,                        \/\/ Module API Version\n    NULL,                        \/\/ Module information\n    STANDARD_MODULE_PROPERTIES\n};\n\n#ifdef COMPILE_DL_MY_EXTENSION\nZEND_GET_MODULE(my_extension)\n#endif<\/pre>\n<p>\u8981\u4f7f\u7528\u8be5\u51fd\u6570\uff0c\u9700\u8981\u5728 PHP \u4ee3\u7801\u4e2d\u5f15\u7528\u5b83\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;?php\nmy_function();<\/pre>\n<p>\u5f53\u6267\u884c\u6b64\u811a\u672c\u65f6\uff0cPHP \u89e3\u91ca\u5668\u5c06\u67e5\u627e &#8220;my_function&#8221; \u51fd\u6570\u5e76\u5728 &#8220;my_extension&#8221; \u51fd\u6570\u8868\u4e2d\u627e\u5230\u5176\u6761\u76ee\uff0c\u7136\u540e\u8c03\u7528\u6307\u5411\u7684 C \u51fd\u6570\u3002<\/p>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>\u901a\u8fc7\u51fd\u6570\u8868\uff0cPHP \u51fd\u6570\u53ef\u4ee5\u5728 C \u6269\u5c55\u4e2d\u88ab\u8c03\u7528\u3002\u8fd9\u5141\u8bb8\u5f00\u53d1\u8005\u5c06\u81ea\u5b9a\u4e49\u529f\u80fd\u96c6\u6210\u5230 PHP \u73af\u5883\u4e2d\uff0c\u4ece\u800c\u6269\u5c55 PHP \u7684\u529f\u80fd\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aPHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8ephp,C\u6269\u5c55\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f \u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\u300aPHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f\u300b\uff0c\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u77e5\u8bc6\u70b9\u5305\u62ec\u7b49\u7b49\uff0c\u65e0\u8bba\u4f60\u662f\u5c0f\u767d\u8fd8\u662f\u8001\u624b\uff0c\u90fd\u9002\u5408\u770b\u4e00\u770b\u54e6~\u6709\u597d\u7684\u5efa\u8bae\u4e5f\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u82e5\u662f\u770b\u5b8c\u6709\u6240\u6536\u83b7\uff0c\u4e5f\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u70b9\u8d5e\u652f\u6301\u5440\uff01\u4e00\u8d77\u52a0\u6cb9\u5b66\u4e60~ PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u901a\u8fc7\u51fd\u6570\u8868\u5b9e\u73b0\u3002\u51fd\u6570\u8868\u662f\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\uff0c\u5b58\u50a8 PHP \u51fd\u6570\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u6307\u5411 C \u51fd\u6570\u7684\u6307\u9488\u3002\u5f53 PHP \u9047\u5230\u6269\u5c55\u51fd\u6570\u65f6\uff0c\u5b83\u4f1a\u5728\u51fd\u6570\u8868\u4e2d\u67e5\u627e\u8be5\u51fd\u6570\uff0c\u5e76\u8c03\u7528\u6307\u5411\u7684 C \u51fd\u6570\u3002\u4f8b\u5982\uff0c\u8981\u5b9a\u4e49\u5e76\u6ce8\u518c &#8220;my_function&#8221; \u51fd\u6570\uff0c\u9700\u521b\u5efa\u51fd\u6570\u8868\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u6269\u5c55\u6a21\u5757\u4e2d\uff0c\u7136\u540e\u5728 PHP \u4ee3\u7801\u4e2d\u5f15\u7528\u8be5\u51fd\u6570\u3002 PHP \u51fd\u6570\u5728 C \u6269\u5c55\u4e2d\u7684\u8c03\u7528\u662f\u5982\u4f55\u5b9e\u73b0\u7684 PHP \u662f\u7531 C \u7f16\u5199\u7684\uff0c\u56e0\u6b64 C \u6269\u5c55\u672c\u8d28\u4e0a\u662f PHP \u89e3\u91ca\u5668\u548c C \u4ee3\u7801\u4e4b\u95f4\u7684\u63a5\u53e3\u3002\u5f53 PHP \u6269\u5c55\u4e2d\u521b\u5efa\u51fd\u6570\u65f6\uff0c\u9700\u8981\u4e00\u4e2a\u673a\u5236\u6765\u5c06\u8fd9\u4e9b\u51fd\u6570\u4e0e PHP \u89e3\u91ca\u5668\u8fde\u63a5\u8d77\u6765\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fd9\u4e2a\u673a\u5236\uff0c\u5e76\u901a\u8fc7\u5b9e\u6218\u6848\u4f8b\u8bf4\u660e\u5176\u5de5\u4f5c\u539f\u7406\u3002 \u65b9\u6cd5 PHP \u4f7f\u7528\u4e00\u4e2a\u540d\u4e3a Function Table\uff08\u51fd\u6570\u8868\uff09\u7684\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u6709\u5173 PHP \u51fd\u6570\u7684\u4fe1\u606f\u3002\u6bcf\u4e2a\u6269\u5c55\u90fd\u53ef\u4ee5\u6ce8\u518c\u81ea\u5df1\u7684\u51fd\u6570\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6307\u5411 C \u51fd\u6570\u7684\u6307\u9488\u3002\u5f53 PHP \u9047\u5230\u9700\u8981\u6267\u884c\u7684\u6269\u5c55\u51fd\u6570\u65f6\uff0c\u5b83\u4f1a\u5728\u51fd\u6570\u8868\u4e2d\u67e5\u627e\u8be5\u51fd\u6570\uff0c\u7136\u540e\u8c03\u7528\u6307\u5411\u7684 C \u51fd\u6570\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-47615","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=47615"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47615\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}