{"id":47846,"date":"2024-12-02T11:46:11","date_gmt":"2024-12-02T03:46:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47846\/"},"modified":"2024-12-02T11:46:11","modified_gmt":"2024-12-02T03:46:11","slug":"%e5%a6%82%e4%bd%95%e8%b0%83%e6%95%b4-php-%e5%87%bd%e6%95%b0%e7%9a%84%e5%a0%86%e6%a0%88%e5%a4%a7%e5%b0%8f%e4%bb%a5%e9%81%bf%e5%85%8d%e6%ba%a2%e5%87%ba","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47846\/","title":{"rendered":"\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u5411\u5927\u5bb6\u4ecb\u7ecd\u300a\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa\u300b\uff0c\u4e3b\u8981\u5305\u62ec\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\u3002<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u5806\u6808\u6ea2\u51fa\uff0c\u53ef\u4ee5\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u3002\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 memory_limit \u8bbe\u7f6e\u6765\u8c03\u6574\u5806\u6808\u5927\u5c0f\uff0c\u6307\u5b9a\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528\u7684\u6700\u5927\u5185\u5b58\u91cf\uff0c\u5305\u62ec\u5806\u6808\u3002\u4f8b\u5982\uff0c\u5c06\u51fd\u6570\u5806\u6808\u5927\u5c0f\u589e\u52a0\u5230 4MB\uff1aini_set(&#8216;memory_limit&#8217;, &#8216;4M&#8217;);\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u9012\u5f52\u51fd\u6570\u6216\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u51fa\u73b0\u7684\u5806\u6808\u6ea2\u51fa\u9519\u8bef\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729939717671cc905c377d.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa\u63d2\u56fe\" alt=\"\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa<\/strong><\/p>\n<p><strong>\u6982\u8ff0<\/strong><\/p>\n<p>\u51fd\u6570\u8c03\u7528\u548c\u5c40\u90e8\u53d8\u91cf\u7684\u5b58\u50a8\u9700\u8981\u5806\u6808\u5185\u5b58\u3002\u5f53\u5806\u6808\u5185\u5b58\u7528\u5c3d\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u5806\u6808\u6ea2\u51fa\u9519\u8bef\u3002\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u6765\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n<p><strong>\u8c03\u6574\u5806\u6808\u5927\u5c0f<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 <code>memory_limit<\/code> \u8bbe\u7f6e\u6765\u8c03\u6574\u5806\u6808\u5927\u5c0f\u3002\u5b83\u6307\u5b9a\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528\u7684\u6700\u5927\u5185\u5b58\u91cf\uff0c\u5305\u62ec\u5806\u6808\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u8c03\u6574\u5806\u6808\u5927\u5c0f\uff1a<\/p>\n<pre>\/\/ \u5c06\u51fd\u6570\u5806\u6808\u5927\u5c0f\u589e\u52a0\u5230 4MB\nini_set('memory_limit', '4M');<\/pre>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u8003\u8651\u4e00\u4e2a\u9012\u5f52\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u8ba1\u7b97\u6590\u6ce2\u90a3\u5951\u6570\u3002\u9012\u5f52\u8c03\u7528\u4f1a\u5bfc\u81f4\u5806\u6808\u5feb\u901f\u589e\u957f\uff0c\u6700\u7ec8\u5bfc\u81f4\u5806\u6808\u6ea2\u51fa\u3002<\/p>\n<pre>function fibonacci($n) {\n    if ($n == 0) {\n        return 0;\n    } elseif ($n == 1) {\n        return 1;\n    } else {\n        return fibonacci($n - 1) + fibonacci($n - 2);\n    }\n}<\/pre>\n<p>\u5728\u8fd9\u4e2a\u6848\u4f8b\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u589e\u52a0\u51fd\u6570\u5806\u6808\u5927\u5c0f\u6765\u907f\u514d\u6ea2\u51fa\uff1a<\/p>\n<pre>ini_set('memory_limit', '10M');\n\n\/\/ \u8ba1\u7b97\u6590\u6ce2\u90a3\u5951\u6570\n$result = fibonacci(40);<\/pre>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>\u901a\u8fc7\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\uff0c\u53ef\u4ee5\u907f\u514d\u5806\u6808\u6ea2\u51fa\u9519\u8bef\u3002\u8fd9\u5bf9\u4e8e\u9012\u5f52\u51fd\u6570\u6216\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u5c24\u5176\u91cd\u8981\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\u7c73\u4e91\uff01\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa \u672c\u7bc7\u6587\u7ae0\u5411\u5927\u5bb6\u4ecb\u7ecd\u300a\u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa\u300b\uff0c\u4e3b\u8981\u5305\u62ec\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\u3002 \u4e3a\u4e86\u907f\u514d\u5806\u6808\u6ea2\u51fa\uff0c\u53ef\u4ee5\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u3002\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 memory_limit \u8bbe\u7f6e\u6765\u8c03\u6574\u5806\u6808\u5927\u5c0f\uff0c\u6307\u5b9a\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528\u7684\u6700\u5927\u5185\u5b58\u91cf\uff0c\u5305\u62ec\u5806\u6808\u3002\u4f8b\u5982\uff0c\u5c06\u51fd\u6570\u5806\u6808\u5927\u5c0f\u589e\u52a0\u5230 4MB\uff1aini_set(&#8216;memory_limit&#8217;, &#8216;4M&#8217;);\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u9012\u5f52\u51fd\u6570\u6216\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u51fa\u73b0\u7684\u5806\u6808\u6ea2\u51fa\u9519\u8bef\u3002 \u5982\u4f55\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u4ee5\u907f\u514d\u6ea2\u51fa \u6982\u8ff0 \u51fd\u6570\u8c03\u7528\u548c\u5c40\u90e8\u53d8\u91cf\u7684\u5b58\u50a8\u9700\u8981\u5806\u6808\u5185\u5b58\u3002\u5f53\u5806\u6808\u5185\u5b58\u7528\u5c3d\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u5806\u6808\u6ea2\u51fa\u9519\u8bef\u3002\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574 PHP \u51fd\u6570\u7684\u5806\u6808\u5927\u5c0f\u6765\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002 \u8c03\u6574\u5806\u6808\u5927\u5c0f \u53ef\u4ee5\u4f7f\u7528 memory_limit \u8bbe\u7f6e\u6765\u8c03\u6574\u5806\u6808\u5927\u5c0f\u3002\u5b83\u6307\u5b9a\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528\u7684\u6700\u5927\u5185\u5b58\u91cf\uff0c\u5305\u62ec\u5806\u6808\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u8c03\u6574\u5806\u6808\u5927\u5c0f\uff1a \/\/ \u5c06\u51fd\u6570\u5806\u6808\u5927\u5c0f\u589e\u52a0\u5230 4MB ini_set(&#8216;memory_limit&#8217;, &#8216;4M&#8217;); \u5b9e\u6218\u6848\u4f8b \u8003\u8651\u4e00\u4e2a\u9012\u5f52\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u8ba1\u7b97\u6590\u6ce2\u90a3\u5951\u6570\u3002\u9012\u5f52\u8c03\u7528\u4f1a\u5bfc\u81f4\u5806\u6808\u5feb\u901f\u589e\u957f\uff0c\u6700\u7ec8\u5bfc\u81f4\u5806\u6808\u6ea2\u51fa\u3002 function fibonacci($n) { if ($n == 0) { return 0; } elseif ($n == 1) { return 1; } else { return fibonacci($n &#8211; [&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-47846","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47846","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=47846"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47846\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}