{"id":48244,"date":"2024-12-02T14:49:09","date_gmt":"2024-12-02T06:49:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48244\/"},"modified":"2024-12-02T14:49:09","modified_gmt":"2024-12-02T06:49:09","slug":"php-%e4%b8%ad%e9%80%92%e5%bd%92%e5%87%bd%e6%95%b0%e7%9a%84%e5%a0%86%e6%a0%88%e9%99%90%e7%95%8c%ef%bc%9a%e5%a6%82%e4%bd%95%e7%a1%ae%e5%ae%9a%e5%92%8c%e8%b0%83%e6%95%b4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48244\/","title":{"rendered":"PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574<\/h1>\n<p>\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\u5417\uff1f\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574\u300b<\/span>\uff0c\u4e3b\u8981\u4ecb\u7ecd\u7684\u5185\u5bb9\u5c31\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u5982\u679c\u4f60\u60f3\u63d0\u5347\u81ea\u5df1\u7684\u5f00\u53d1\u80fd\u529b\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5927\u5bb6\u8981\u77e5\u9053\u7f16\u7a0b\u7406\u8bba\u57fa\u7840\u548c\u5b9e\u6218\u64cd\u4f5c\u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u54e6\uff01<\/p>\n<p>PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\u9ed8\u8ba4\u503c\u4e3a 100\uff0c\u53ef\u901a\u8fc7 echo ini_get(&#8216;max_recursion_depth&#8217;) \u786e\u5b9a\u3002\u8c03\u6574\u5806\u6808\u9650\u754c\u9700\u8981\u4fee\u6539 PHP.ini \u6587\u4ef6\u4e2d\u7684 max_recursion_depth \u8bbe\u7f6e\u3002\u5bf9\u4e8e\u8f83\u5927\u7684\u9012\u5f52\u51fd\u6570\uff0c\u5982\u9636\u4e58\u8ba1\u7b97\uff0c\u901a\u8fc7\u589e\u52a0\u5806\u6808\u9650\u754c\u53ef\u4ee5\u907f\u514d\u5806\u6808\u7a7a\u95f4\u8017\u5c3d\u3002\u4f46\u662f\uff0c\u5e94\u8c28\u614e\u8c03\u6574\uff0c\u56e0\u4e3a\u8fc7\u9ad8\u7684\u503c\u53ef\u80fd\u5bfc\u81f4\u5185\u5b58\u4e0d\u8db3\u3002\u6b64\u5916\uff0c\u5806\u6808\u9650\u754c\u7684\u589e\u52a0\u53ef\u80fd\u4f1a\u964d\u4f4e\u9012\u5f52\u51fd\u6570\u7684\u6027\u80fd\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241027\/1730004580671dc66408abd.jpg\" class=\"aligncenter\" title=\"PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574\u63d2\u56fe\" alt=\"PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574<\/strong><\/p>\n<p><strong>\u7b80\u4ecb<\/strong><\/p>\n<p>\u9012\u5f52\u51fd\u6570\u662f\u6307\u4f1a\u5728\u51fd\u6570\u5185\u90e8\u8c03\u7528\u81ea\u8eab\u4ee5\u89e3\u51b3\u95ee\u9898\u7684\u51fd\u6570\u3002\u5728 PHP \u4e2d\uff0c\u9012\u5f52\u51fd\u6570\u4f7f\u7528\u7684\u5806\u6808\u7a7a\u95f4\u6709\u9650\uff0c\u5982\u679c\u5806\u6808\u4f7f\u7528\u91cf\u8d85\u8fc7\u6b64\u9650\u754c\uff0c\u5219\u4f1a\u629b\u51fa\u4e00\u4e2a &#8220;Fatal error: Maximum function nesting level of &#8216;100&#8217; reached&#8221; \u7684\u9519\u8bef\u3002<\/p>\n<p><strong>\u786e\u5b9a\u5806\u6808\u9650\u754c<\/strong><\/p>\n<p>\u8981\u786e\u5b9a\u5f53\u524d PHP \u5b89\u88c5\u7684\u5806\u6808\u9650\u754c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>echo ini_get('max_recursion_depth');<\/pre>\n<p>\u8fd9\u5c06\u663e\u793a\u4e00\u4e2a\u6570\u5b57\uff0c\u8868\u793a\u53ef\u4ee5\u5d4c\u5957\u8c03\u7528\u7684\u6700\u5927\u51fd\u6570\u6570\u91cf\u3002\u9ed8\u8ba4\u503c\u901a\u5e38\u4e3a 100\u3002<\/p>\n<p><strong>\u8c03\u6574\u5806\u6808\u9650\u754c<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 PHP.ini \u6587\u4ef6\u6765\u8c03\u6574\u5806\u6808\u9650\u754c\uff1a<\/p>\n<pre>max_recursion_depth = X<\/pre>\n<p>\u5176\u4e2d <code>X<\/code> \u662f\u6240\u9700\u7684\u5806\u6808\u9650\u754c\u3002\u4fdd\u5b58 PHP.ini \u6587\u4ef6\u5e76\u91cd\u65b0\u542f\u52a8 Web \u670d\u52a1\u5668\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528\u9012\u5f52\u51fd\u6570\u8ba1\u7b97\u9636\u4e58\u7684 PHP \u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>function factorial($n) {\n  if ($n &lt;= 1) {\n    return 1;\n  }\n  \n  return $n * factorial($n - 1);\n}<\/pre>\n<p>\u5bf9\u4e8e\u8f83\u5927\u7684 <code>n<\/code> \u503c\uff0c\u8be5\u51fd\u6570\u53ef\u80fd\u4f1a\u8017\u5c3d\u5806\u6808\u7a7a\u95f4\u3002\u901a\u8fc7\u5c06 <code>max_recursion_depth<\/code> \u589e\u52a0\u5230\u4e00\u4e2a\u66f4\u9ad8\u7684\u503c\uff08\u4f8b\u5982 500\uff09\uff0c\u53ef\u4ee5\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<p>\u8bf7\u8c28\u614e\u8c03\u6574\u5806\u6808\u9650\u754c\uff0c\u56e0\u4e3a\u8fc7\u9ad8\u7684\u503c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5185\u5b58\u4e0d\u8db3\u3002\u8fd8\u5e94\u6ce8\u610f\uff0c\u9012\u5f52\u51fd\u6570\u7684\u6027\u80fd\u53ef\u80fd\u4f1a\u968f\u5806\u6808\u9650\u754c\u7684\u589e\u52a0\u800c\u4e0b\u964d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aPHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8ephp,\u9012\u5f52\u51fd\u6570\u5806\u6808\u9650\u754c\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574 \u4f60\u5728\u5b66\u4e60\u6587\u7ae0\u76f8\u5173\u7684\u77e5\u8bc6\u5417\uff1f\u672c\u6587\u300aPHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u7684\u5185\u5bb9\u5c31\u6d89\u53ca\u5230\uff0c\u5982\u679c\u4f60\u60f3\u63d0\u5347\u81ea\u5df1\u7684\u5f00\u53d1\u80fd\u529b\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5927\u5bb6\u8981\u77e5\u9053\u7f16\u7a0b\u7406\u8bba\u57fa\u7840\u548c\u5b9e\u6218\u64cd\u4f5c\u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u54e6\uff01 PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\u9ed8\u8ba4\u503c\u4e3a 100\uff0c\u53ef\u901a\u8fc7 echo ini_get(&#8216;max_recursion_depth&#8217;) \u786e\u5b9a\u3002\u8c03\u6574\u5806\u6808\u9650\u754c\u9700\u8981\u4fee\u6539 PHP.ini \u6587\u4ef6\u4e2d\u7684 max_recursion_depth \u8bbe\u7f6e\u3002\u5bf9\u4e8e\u8f83\u5927\u7684\u9012\u5f52\u51fd\u6570\uff0c\u5982\u9636\u4e58\u8ba1\u7b97\uff0c\u901a\u8fc7\u589e\u52a0\u5806\u6808\u9650\u754c\u53ef\u4ee5\u907f\u514d\u5806\u6808\u7a7a\u95f4\u8017\u5c3d\u3002\u4f46\u662f\uff0c\u5e94\u8c28\u614e\u8c03\u6574\uff0c\u56e0\u4e3a\u8fc7\u9ad8\u7684\u503c\u53ef\u80fd\u5bfc\u81f4\u5185\u5b58\u4e0d\u8db3\u3002\u6b64\u5916\uff0c\u5806\u6808\u9650\u754c\u7684\u589e\u52a0\u53ef\u80fd\u4f1a\u964d\u4f4e\u9012\u5f52\u51fd\u6570\u7684\u6027\u80fd\u3002 PHP \u4e2d\u9012\u5f52\u51fd\u6570\u7684\u5806\u6808\u9650\u754c\uff1a\u5982\u4f55\u786e\u5b9a\u548c\u8c03\u6574 \u7b80\u4ecb \u9012\u5f52\u51fd\u6570\u662f\u6307\u4f1a\u5728\u51fd\u6570\u5185\u90e8\u8c03\u7528\u81ea\u8eab\u4ee5\u89e3\u51b3\u95ee\u9898\u7684\u51fd\u6570\u3002\u5728 PHP \u4e2d\uff0c\u9012\u5f52\u51fd\u6570\u4f7f\u7528\u7684\u5806\u6808\u7a7a\u95f4\u6709\u9650\uff0c\u5982\u679c\u5806\u6808\u4f7f\u7528\u91cf\u8d85\u8fc7\u6b64\u9650\u754c\uff0c\u5219\u4f1a\u629b\u51fa\u4e00\u4e2a &#8220;Fatal error: Maximum function nesting level of &#8216;100&#8217; reached&#8221; \u7684\u9519\u8bef\u3002 \u786e\u5b9a\u5806\u6808\u9650\u754c \u8981\u786e\u5b9a\u5f53\u524d PHP \u5b89\u88c5\u7684\u5806\u6808\u9650\u754c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a echo ini_get(&#8216;max_recursion_depth&#8217;); \u8fd9\u5c06\u663e\u793a\u4e00\u4e2a\u6570\u5b57\uff0c\u8868\u793a\u53ef\u4ee5\u5d4c\u5957\u8c03\u7528\u7684\u6700\u5927\u51fd\u6570\u6570\u91cf\u3002\u9ed8\u8ba4\u503c\u901a\u5e38\u4e3a 100\u3002 \u8c03\u6574\u5806\u6808\u9650\u754c \u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 PHP.ini \u6587\u4ef6\u6765\u8c03\u6574\u5806\u6808\u9650\u754c\uff1a max_recursion_depth = X \u5176\u4e2d X \u662f\u6240\u9700\u7684\u5806\u6808\u9650\u754c\u3002\u4fdd\u5b58 PHP.ini \u6587\u4ef6\u5e76\u91cd\u65b0\u542f\u52a8 Web \u670d\u52a1\u5668\u4ee5\u5e94\u7528\u66f4\u6539\u3002 \u5b9e\u6218\u6848\u4f8b \u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528\u9012\u5f52\u51fd\u6570\u8ba1\u7b97\u9636\u4e58\u7684 PHP [&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-48244","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48244","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=48244"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48244\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}