{"id":46815,"date":"2024-12-02T16:50:39","date_gmt":"2024-12-02T08:50:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/46815\/"},"modified":"2024-12-02T16:50:39","modified_gmt":"2024-12-02T08:50:39","slug":"%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87-php-%e9%80%92%e5%bd%92%e5%87%bd%e6%95%b0%e5%88%9b%e5%bb%ba%e8%87%aa%e7%9b%b8%e5%85%b3%e5%9b%be%e5%bd%a2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/46815\/","title":{"rendered":"\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62<\/h1>\n<p>\u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u7c73\u4e91\u5c31\u6574\u7406\u5206\u4eab\u300a\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u7c73\u4e91\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002<\/p>\n<p>PHP \u9012\u5f52\u51fd\u6570\u53ef\u521b\u5efa\u81ea\u76f8\u4f3c\u56fe\u5f62\uff0c\u901a\u8fc7\u8c03\u7528\u81ea\u8eab\u89e3\u51b3\u95ee\u9898\u3002\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a\u5b9a\u4e49\u9012\u5f52\u51fd\u6570\u8bbe\u7f6e\u957f\u5ea6\u3001\u5c42\u7ea7\u548c\u89d2\u5ea6\u3002\u6839\u636e\u5c42\u7ea7\uff0c\u751f\u6210\u5de6\u3001\u4e2d\u3001\u53f3\u4e09\u4e2a\u56fe\u5f62\u7247\u6bb5\u3002\u5408\u5e76\u4e09\u4e2a\u7247\u6bb5\uff0c\u5f62\u6210\u4e00\u4e2a\u65b0\u7684\u56fe\u5f62\u3002\u5faa\u73af\u66f4\u65b0\u5750\u6807\uff0c\u7ed8\u5236\u56fe\u5f62\u3002\u8bbe\u7f6e\u4e0d\u540c\u7684\u9012\u5f52\u5c42\u7ea7\uff0c\u63a7\u5236\u56fe\u5f62\u590d\u6742\u5ea6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241025\/1729848228671b63a4a52b1.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62\u63d2\u56fe\" alt=\"\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u4f3c\u56fe\u5f62<\/strong><\/p>\n<p>\u9012\u5f52\u51fd\u6570\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u51fd\u6570\uff0c\u53ef\u4ee5\u8c03\u7528\u81ea\u8eab\u6765\u89e3\u51b3\u95ee\u9898\u3002\u5728\u7f16\u7a0b\u4e2d\uff0c\u9012\u5f52\u51fd\u6570\u7ecf\u5e38\u7528\u4e8e\u751f\u6210\u81ea\u76f8\u4f3c\u56fe\u5f62\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u56fe\u5f62\u5177\u6709\u5206\u5f62\u7ed3\u6784\u7684\u7279\u70b9\uff0c\u5373\u4e00\u90e8\u5206\u4e0e\u6574\u4f53\u76f8\u4f3c\u3002<\/p>\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4f7f\u7528 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u4f3c\u56fe\u5f62\u7684\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>function kochCurve($length, $level, $angle) {\n  if ($level == 0) {\n    return array(array($length, $angle));\n  } else {\n    $left = kochCurve($length \/ 3, $level - 1, -$angle);\n    $right = kochCurve($length \/ 3, $level - 1, $angle);\n    $middle = kochCurve($length \/ 3, $level - 1, -$angle);\n    return array_merge($left, $middle, $right);\n  }\n}\n\n$curve = kochCurve(100, 4, 90);\n\n$x = 0;\n$y = 0;\nforeach ($curve as $segment) {\n  $x += $segment[0] * cos(deg2rad($segment[1]));\n  $y += $segment[0] * sin(deg2rad($segment[1]));\n  echo \"$x,$y\\n\";\n}<\/pre>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u6b64\u4ee3\u7801\u751f\u6210\u79d1\u8d6b\u96ea\u82b1\u56fe\u5f62\uff0c\u8fd9\u662f\u4e00\u79cd\u7531\u4e09\u6761\u79d1\u8d6b\u66f2\u7ebf\u548c\u6210\u7684\u5bf9\u79f0\u66f2\u7ebf\u3002\u901a\u8fc7\u8bbe\u7f6e\u4e0d\u540c\u7684\u9012\u5f52\u7ea7\u522b\u6765\u63a7\u5236\u56fe\u5f62\u7684\u590d\u6742\u7a0b\u5ea6\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u9012\u5f52\u7ea7\u522b<\/th>\n<th>\u56fe\u5f62\u6548\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>\u4e09\u6761\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>\u4e5d\u6761\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>\u4e8c\u5341\u4e03\u6761\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>\u516b\u5341\u4e00\u6761\u7ebf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u7ed3\u8bed<\/strong><\/p>\n<p>\u901a\u8fc7\u5229\u7528 PHP \u9012\u5f52\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u590d\u6742\u7684\u81ea\u76f8\u4f3c\u56fe\u5f62\uff0c\u4ee5\u53ca\u5176\u4ed6\u5e7f\u6cdb\u7684\u8ba1\u7b97\u95ee\u9898\u3002\u8fd9\u4e9b\u56fe\u5f62\u5728\u81ea\u7136\u89c2\u5bdf\u3001\u6570\u5b66\u548c\u7f8e\u5b66\u7b49\u9886\u57df\u90fd\u6709\u5e94\u7528\u3002<\/p>\n<p>\u6587\u4e2d\u5173\u4e8e\u9012\u5f52,\u56fe\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300a\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62 \u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u7c73\u4e91\u5c31\u6574\u7406\u5206\u4eab\u300a\u5982\u4f55\u901a\u8fc7 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u5173\u56fe\u5f62\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u7c73\u4e91\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002 PHP \u9012\u5f52\u51fd\u6570\u53ef\u521b\u5efa\u81ea\u76f8\u4f3c\u56fe\u5f62\uff0c\u901a\u8fc7\u8c03\u7528\u81ea\u8eab\u89e3\u51b3\u95ee\u9898\u3002\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a\u5b9a\u4e49\u9012\u5f52\u51fd\u6570\u8bbe\u7f6e\u957f\u5ea6\u3001\u5c42\u7ea7\u548c\u89d2\u5ea6\u3002\u6839\u636e\u5c42\u7ea7\uff0c\u751f\u6210\u5de6\u3001\u4e2d\u3001\u53f3\u4e09\u4e2a\u56fe\u5f62\u7247\u6bb5\u3002\u5408\u5e76\u4e09\u4e2a\u7247\u6bb5\uff0c\u5f62\u6210\u4e00\u4e2a\u65b0\u7684\u56fe\u5f62\u3002\u5faa\u73af\u66f4\u65b0\u5750\u6807\uff0c\u7ed8\u5236\u56fe\u5f62\u3002\u8bbe\u7f6e\u4e0d\u540c\u7684\u9012\u5f52\u5c42\u7ea7\uff0c\u63a7\u5236\u56fe\u5f62\u590d\u6742\u5ea6\u3002 \u4f7f\u7528 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u4f3c\u56fe\u5f62 \u9012\u5f52\u51fd\u6570\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u51fd\u6570\uff0c\u53ef\u4ee5\u8c03\u7528\u81ea\u8eab\u6765\u89e3\u51b3\u95ee\u9898\u3002\u5728\u7f16\u7a0b\u4e2d\uff0c\u9012\u5f52\u51fd\u6570\u7ecf\u5e38\u7528\u4e8e\u751f\u6210\u81ea\u76f8\u4f3c\u56fe\u5f62\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u56fe\u5f62\u5177\u6709\u5206\u5f62\u7ed3\u6784\u7684\u7279\u70b9\uff0c\u5373\u4e00\u90e8\u5206\u4e0e\u6574\u4f53\u76f8\u4f3c\u3002 \u4ee3\u7801\u5b9e\u73b0 \u4ee5\u4e0b\u662f\u4f7f\u7528 PHP \u9012\u5f52\u51fd\u6570\u521b\u5efa\u81ea\u76f8\u4f3c\u56fe\u5f62\u7684\u4ee3\u7801\u793a\u4f8b\uff1a function kochCurve($length, $level, $angle) { if ($level == 0) { return array(array($length, $angle)); } else { $left = kochCurve($length \/ 3, $level &#8211; 1, -$angle); $right = kochCurve($length \/ 3, $level &#8211; 1, $angle); $middle = kochCurve($length \/ 3, [&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-46815","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/46815","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=46815"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/46815\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=46815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=46815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=46815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}