{"id":48832,"date":"2024-12-02T08:04:49","date_gmt":"2024-12-02T00:04:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48832\/"},"modified":"2024-12-02T08:04:49","modified_gmt":"2024-12-02T00:04:49","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e8%bd%ac%e7%9b%98%e6%8a%bd%e5%a5%96%e4%b8%8e-php-%e5%90%8e%e7%ab%af%e9%9b%86%e6%88%90%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48832\/","title":{"rendered":"\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\uff1f<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\uff1f\u300b<\/span>\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span><\/span>\uff0c\u5982\u679c\u4f60\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241101\/173044751267248898b99b5.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6c42\u5927\u795e\u89e3\u7b54\u8f6c\u76d8\u62bd\u5956<\/strong><\/p>\n<p>\u672c\u6587\u5c06\u63a2\u8ba8\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e php \u540e\u7aef\u96c6\u6210\uff0c\u5305\u62ec\u7528\u6237\u884c\u4e3a\u89e6\u53d1\u3001\u6570\u636e\u4f20\u8f93\u548c\u540e\u7aef\u54cd\u5e94\u3002<\/p>\n<h3>\u524d\u7aef\u811a\u672c<\/h3>\n<p>\u63d0\u4f9b\u7684\u4ee3\u7801\u7247\u6bb5\u5c55\u793a\u4e86\u4e00\u4e2a\u8f6c\u76d8\u62bd\u5956\u7684\u5b9e\u73b0\uff0c\u5176\u4e2d\u7528\u6237\u70b9\u51fb\u7bad\u5934\u540e\u4f1a\u89e6\u53d1\u4e00\u4e2a\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u4f1a\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u7ed3\u679c\u5e76\u5c06\u5176\u663e\u793a\u5728\u7ed3\u679c\u9762\u677f\u4e2d\u3002<\/p>\n<h3>ajax \u6570\u636e\u4f20\u8f93<\/h3>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u4e0e\u540e\u7aef\u7684\u4ea4\u4e92\uff0c\u9700\u8981\u6dfb\u52a0 ajax \u4ee3\u7801\u5411 php \u811a\u672c\u53d1\u9001\u8bf7\u6c42\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4fee\u6539\u4ee3\u7801\uff1a<\/p>\n<pre>$rotaryarrow.click(function(){\n    $.ajax({\n        url: \"path\/to\/script.php\",\n        type: \"post\",\n        data: { action: \"draw\" },\n        success: function(response) {\n            var data = json.parse(response);  \/\/ \u5047\u8bbe php \u54cd\u5e94\u4e3a json \u683c\u5f0f\n            rotatefunc(data.result, data.angle, data.text);\n        }\n    });\n});<\/pre>\n<h3>php \u540e\u7aef\u811a\u672c<\/h3>\n<p>php \u811a\u672c\u5c06\u8d1f\u8d23\u5904\u7406 ajax \u8bf7\u6c42\u5e76\u8fd4\u56de\u62bd\u5956\u7ed3\u679c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u811a\u672c\uff1a<\/p>\n<pre>&lt;?php\n\n\/\/ \u5904\u7406\u8bf7\u6c42\nif (isset($_POST['action'])) {\n    switch ($_POST['action']) {\n        case 'draw':\n            \/\/ \u751f\u6210\u968f\u673a\u7ed3\u679c\n            $result = rand(0, 7);\n            $angle = $result * 45;\n            $text = \"\";  \/\/ \u6839\u636e\u7ed3\u679c\u8bbe\u7f6e\u6587\u672c\uff08\u4f8b\u5982\uff1a\"&lt;em&gt;1&lt;\/em&gt;\"\uff09\n\n            \/\/ \u8f93\u51fa JSON \u54cd\u5e94\n            echo json_encode(['result' =&gt; $result, 'angle' =&gt; $angle, 'text' =&gt; $text]);\n            break;\n    }\n}\n?&gt;<\/pre>\n<h3>\u6ce8\u610f<\/h3>\n<ul>\n<li>\u786e\u4fdd php \u811a\u672c\u5177\u6709\u5fc5\u8981\u7684\u6743\u9650\u548c\u9632\u706b\u5899\u89c4\u5219\u4ee5\u63a5\u53d7\u8bf7\u6c42\u3002<\/li>\n<li>\u5728\u5b9e\u9645\u5b9e\u73b0\u4e2d\uff0c\u8bf7\u4f7f\u7528\u9002\u5f53\u7684\u9a8c\u8bc1\u548c\u9519\u8bef\u5904\u7406\u4ee5\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u5b89\u5168\u548c\u7a33\u5b9a\u3002<\/li>\n<\/ul>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\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\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\uff1f \u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0\u300a\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e PHP \u540e\u7aef\u96c6\u6210\uff1f\u300b\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01 \u6c42\u5927\u795e\u89e3\u7b54\u8f6c\u76d8\u62bd\u5956 \u672c\u6587\u5c06\u63a2\u8ba8\u5982\u4f55\u5c06\u8f6c\u76d8\u62bd\u5956\u4e0e php \u540e\u7aef\u96c6\u6210\uff0c\u5305\u62ec\u7528\u6237\u884c\u4e3a\u89e6\u53d1\u3001\u6570\u636e\u4f20\u8f93\u548c\u540e\u7aef\u54cd\u5e94\u3002 \u524d\u7aef\u811a\u672c \u63d0\u4f9b\u7684\u4ee3\u7801\u7247\u6bb5\u5c55\u793a\u4e86\u4e00\u4e2a\u8f6c\u76d8\u62bd\u5956\u7684\u5b9e\u73b0\uff0c\u5176\u4e2d\u7528\u6237\u70b9\u51fb\u7bad\u5934\u540e\u4f1a\u89e6\u53d1\u4e00\u4e2a\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u4f1a\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u7ed3\u679c\u5e76\u5c06\u5176\u663e\u793a\u5728\u7ed3\u679c\u9762\u677f\u4e2d\u3002 ajax \u6570\u636e\u4f20\u8f93 \u4e3a\u4e86\u5b9e\u73b0\u4e0e\u540e\u7aef\u7684\u4ea4\u4e92\uff0c\u9700\u8981\u6dfb\u52a0 ajax \u4ee3\u7801\u5411 php \u811a\u672c\u53d1\u9001\u8bf7\u6c42\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4fee\u6539\u4ee3\u7801\uff1a $rotaryarrow.click(function(){ $.ajax({ url: &#8220;path\/to\/script.php&#8221;, type: &#8220;post&#8221;, data: { action: &#8220;draw&#8221; }, success: function(response) { var data = json.parse(response); \/\/ \u5047\u8bbe php \u54cd\u5e94\u4e3a json \u683c\u5f0f rotatefunc(data.result, data.angle, data.text); } }); }); php \u540e\u7aef\u811a\u672c php \u811a\u672c\u5c06\u8d1f\u8d23\u5904\u7406 ajax \u8bf7\u6c42\u5e76\u8fd4\u56de\u62bd\u5956\u7ed3\u679c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u811a\u672c\uff1a [&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-48832","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48832","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=48832"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48832\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}