{"id":47347,"date":"2024-12-02T16:31:35","date_gmt":"2024-12-02T08:31:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47347\/"},"modified":"2024-12-02T16:31:35","modified_gmt":"2024-12-02T08:31:35","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-php-%e5%87%bd%e6%95%b0%e6%89%a9%e5%b1%95%e6%9d%a5%e6%89%a9%e5%b1%95-php-%e8%af%ad%e8%a8%80%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47347\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f<\/h1>\n<p>\u6b22\u8fce\u5404\u4f4d\u5c0f\u4f19\u4f34\u6765\u5230\u7c73\u4e91\uff0c\u76f8\u805a\u4e8e\u6b64\u90fd\u662f\u7f18\u54c8\u54c8\u54c8\uff01\u4eca\u5929\u6211\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f\u300b<\/span>\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\uff0c\u5982\u679c\u4f60\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\u975e\u5e38\u611f\u5174\u8da3\u6216\u8005\u6b63\u5728\u81ea\u5b66\uff0c\u90fd\u53ef\u4ee5\u5173\u6ce8\u6211\uff0c\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u6587\u7ae0\uff01\u5f53\u7136\uff0c\u6709\u4ec0\u4e48\u5efa\u8bae\u4e5f\u6b22\u8fce\u5728\u8bc4\u8bba\u7559\u8a00\u63d0\u51fa\uff01\u4e00\u8d77\u5b66\u4e60\uff01<\/p>\n<p>\u5982\u4f55\u6269\u5c55 PHP \u8bed\u8a00\u529f\u80fd\uff1f\u4f7f\u7528 C \u8bed\u8a00\u521b\u5efa PHP \u51fd\u6570\u6269\u5c55\uff0c\u6dfb\u52a0\u65b0\u7684\u51fd\u6570\u3001\u7c7b\u548c\u5e38\u91cf\u3002\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5 PHP \u5f00\u53d1\u5de5\u5177\u3002\u4f7f\u7528 C \u8bed\u8a00\u521b\u5efa\u6269\u5c55\u3002\u4f7f\u7528 PECL \u7f16\u8bd1\u6269\u5c55\u3002\u6dfb\u52a0\u6269\u5c55\u5230 php.ini \u6587\u4ef6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729912057671c5cf96add3.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd<\/strong><\/p>\n<p>PHP \u51fd\u6570\u6269\u5c55\u662f\u4e00\u79cd\u4f7f\u7528 C \u8bed\u8a00\u7f16\u5199\u7684\u5e93\uff0c\u5b83\u53ef\u4ee5\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\u3002\u901a\u8fc7\u521b\u5efa\u6269\u5c55\uff0c\u60a8\u53ef\u4ee5\u6dfb\u52a0\u65b0\u7684\u51fd\u6570\u3001\u7c7b\u548c\u5e38\u91cf\u5230 PHP \u89e3\u91ca\u5668\u4e2d\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li><strong>\u5b89\u88c5 PHP \u5f00\u53d1\u5de5\u5177<\/strong><\/li>\n<\/ol>\n<p>\u4f60\u9700\u8981\u5b89\u88c5 PHP \u5f00\u53d1\u5de5\u5177\uff0c\u6bd4\u5982 PHP \u5f00\u53d1\u73af\u5883 (https:\/\/www.php.net\/downloads.php)\u3002<\/p>\n<ol>\n<li><strong>\u521b\u5efa\u6269\u5c55<\/strong><\/li>\n<\/ol>\n<p>\u4f7f\u7528 C \u8bed\u8a00\u521b\u5efa\u4e00\u4e2a\u6269\u5c55\u5e93\u3002\u8be5\u5e93\u5fc5\u987b\u5305\u542b\u4ee5\u4e0b\u51fd\u6570\uff1a<\/p>\n<ul>\n<li><code>zend_module_entry<\/code>\uff1a\u521d\u59cb\u5316\u6269\u5c55\u7684\u5165\u53e3\u70b9\u3002<\/li>\n<li><code>phpinfo_XXX<\/code>\uff1a\u5728 phpinfo() \u8f93\u51fa\u4e2d\u663e\u793a\u6269\u5c55\u7684\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<ol>\n<li><strong>\u7f16\u8bd1\u6269\u5c55<\/strong><\/li>\n<\/ol>\n<p>\u4f7f\u7528 PHP \u6269\u5c55\u751f\u6210\u5668 (PECL) \u7f16\u8bd1\u6269\u5c55\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>pecl install &lt;\u4f60\u7684\u6269\u5c55\u540d&gt;<\/pre>\n<ol>\n<li><strong>\u542f\u7528\u6269\u5c55<\/strong><\/li>\n<\/ol>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u884c\u5230 php.ini \u6587\u4ef6\u4e2d\u4ee5\u542f\u7528\u6269\u5c55\uff1a<\/p>\n<pre>extension=&lt;\u4f60\u7684\u6269\u5c55\u540d&gt;.so<\/pre>\n<p><strong>\u5b9e\u6218\u6848\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u521b\u5efa\u7b80\u5355\u7684\u6269\u5c55\u6765\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a <code>my_greet<\/code> \u7684\u65b0\u51fd\u6570\u7684\u793a\u4f8b\uff1a<\/p>\n<pre>#include \"php.h\"\n\nzend_function_entry my_functions[] = {\n    PHP_FE(my_greet, NULL)\n    {NULL, NULL, NULL}\n};\n\nZEND_MODULE_GLOBALS(my_greet);\n\nPHP_MINFO_FUNCTION(my_greet)\n{\n    php_info_print_table_start();\n    php_info_print_table_header(2, \"MyGreet Extension\", \"enabled\");\n    php_info_print_table_end();\n}\n\nPHP_FUNCTION(my_greet)\n{\n    char *name;\n    int name_len;\n\n    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &amp;name, &amp;name_len) == FAILURE) {\n        return;\n    }\n\n    php_printf(\"Hello, %s!\", name);\n}\n\nzend_module_entry my_greet_module = {\n    STANDARD_MODULE_HEADER,\n    NULL,\n    NULL,\n    \"my_greet\",\n    my_functions,\n    PHP_MINFO_CALLBACK(my_greet),\n    NULL,\n    NULL,\n    NULL,\n    STANDARD_MODULE_PROPERTIES\n};\n\nZEND_GET_MODULE(my_greet)<\/pre>\n<p>\u7f16\u8bd1\u6b64\u6269\u5c55\u5e76\u542f\u7528\u5b83\uff0c\u60a8\u5c31\u53ef\u4ee5\u4f7f\u7528 <code>my_greet<\/code> \u51fd\u6570\u4e86\u3002\u8c03\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06\u6253\u5370 &#8220;Hello, World!&#8221;:<\/p>\n<pre>&lt;?php\nmy_greet(\"World\");\n?&gt;<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8ephp,\u51fd\u6570\u6269\u5c55\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f \u6b22\u8fce\u5404\u4f4d\u5c0f\u4f19\u4f34\u6765\u5230\u7c73\u4e91\uff0c\u76f8\u805a\u4e8e\u6b64\u90fd\u662f\u7f18\u54c8\u54c8\u54c8\uff01\u4eca\u5929\u6211\u7ed9\u5927\u5bb6\u5e26\u6765\u300a\u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\uff1f\u300b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u76f8\u5173\u7684\u77e5\u8bc6\u975e\u5e38\u611f\u5174\u8da3\u6216\u8005\u6b63\u5728\u81ea\u5b66\uff0c\u90fd\u53ef\u4ee5\u5173\u6ce8\u6211\uff0c\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u6587\u7ae0\uff01\u5f53\u7136\uff0c\u6709\u4ec0\u4e48\u5efa\u8bae\u4e5f\u6b22\u8fce\u5728\u8bc4\u8bba\u7559\u8a00\u63d0\u51fa\uff01\u4e00\u8d77\u5b66\u4e60\uff01 \u5982\u4f55\u6269\u5c55 PHP \u8bed\u8a00\u529f\u80fd\uff1f\u4f7f\u7528 C \u8bed\u8a00\u521b\u5efa PHP \u51fd\u6570\u6269\u5c55\uff0c\u6dfb\u52a0\u65b0\u7684\u51fd\u6570\u3001\u7c7b\u548c\u5e38\u91cf\u3002\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5 PHP \u5f00\u53d1\u5de5\u5177\u3002\u4f7f\u7528 C \u8bed\u8a00\u521b\u5efa\u6269\u5c55\u3002\u4f7f\u7528 PECL \u7f16\u8bd1\u6269\u5c55\u3002\u6dfb\u52a0\u6269\u5c55\u5230 php.ini \u6587\u4ef6\u3002 \u5982\u4f55\u4f7f\u7528 PHP \u51fd\u6570\u6269\u5c55\u6765\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd PHP \u51fd\u6570\u6269\u5c55\u662f\u4e00\u79cd\u4f7f\u7528 C \u8bed\u8a00\u7f16\u5199\u7684\u5e93\uff0c\u5b83\u53ef\u4ee5\u6269\u5c55 PHP \u8bed\u8a00\u7684\u529f\u80fd\u3002\u901a\u8fc7\u521b\u5efa\u6269\u5c55\uff0c\u60a8\u53ef\u4ee5\u6dfb\u52a0\u65b0\u7684\u51fd\u6570\u3001\u7c7b\u548c\u5e38\u91cf\u5230 PHP \u89e3\u91ca\u5668\u4e2d\u3002 \u6b65\u9aa4\uff1a \u5b89\u88c5 PHP \u5f00\u53d1\u5de5\u5177 \u4f60\u9700\u8981\u5b89\u88c5 PHP \u5f00\u53d1\u5de5\u5177\uff0c\u6bd4\u5982 PHP \u5f00\u53d1\u73af\u5883 (https:\/\/www.php.net\/downloads.php)\u3002 \u521b\u5efa\u6269\u5c55 \u4f7f\u7528 C \u8bed\u8a00\u521b\u5efa\u4e00\u4e2a\u6269\u5c55\u5e93\u3002\u8be5\u5e93\u5fc5\u987b\u5305\u542b\u4ee5\u4e0b\u51fd\u6570\uff1a zend_module_entry\uff1a\u521d\u59cb\u5316\u6269\u5c55\u7684\u5165\u53e3\u70b9\u3002 phpinfo_XXX\uff1a\u5728 phpinfo() [&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-47347","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47347","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=47347"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47347\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}