{"id":22712,"date":"2024-11-21T08:46:36","date_gmt":"2024-11-21T00:46:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22712\/"},"modified":"2024-11-21T08:46:36","modified_gmt":"2024-11-21T00:46:36","slug":"thinkphp%e6%80%8e%e4%b9%88%e8%b0%83%e7%94%a8%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22712\/","title":{"rendered":"thinkphp\u600e\u4e48\u8c03\u7528\u51fd\u6570"},"content":{"rendered":"<p>thinkphp\u662f\u4e00\u6b3ephp\u7684\u5f00\u53d1\u6846\u67b6\uff0c\u5176\u4e3a\u5e38\u89c1\u7684web\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5feb\u901f\u3001\u7b80\u5355\u3001\u9ad8\u6548\u53ca\u9ad8\u8d28\u91cf\u7684\u5f00\u53d1\u4f53\u7cfb\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u5f00\u53d1\u4e00\u4e2aweb\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f1a\u591a\u6b21\u4f7f\u7528\u4e00\u4e9b\u65b9\u6cd5\u6216\u51fd\u6570\u3002\u800c\u5728thinkphp\u6846\u67b6\u4e0b\uff0c\u5982\u4f55\u8c03\u7528\u51fd\u6570\u5462\uff1f\u672c\u6587\u5c06\u4e3a\u60a8\u4e00\u4e00\u4ecb\u7ecd\u3002<\/p>\n<p>\u4e00\u3001\u5168\u5c40\u51fd\u6570<\/p>\n<p>ThinkPHP\u6846\u67b6\u5141\u8bb8\u8c03\u7528PHP\u5168\u5c40\u51fd\u6570\u3002\u6bd4\u5982\uff0c\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u89c1\u7684PHP\u5168\u5c40\u51fd\u6570\u3002<\/p>\n<pre>$pos = strpos(\"hello world\", \"world\");\necho $pos;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u662fPHP\u4e2d\u975e\u5e38\u5e38\u89c1\u7684\u51fd\u6570\u4e4b\u4e00\u2014\u2014 strpos() \u3002\u800c\u5728ThinkPHP\u6846\u67b6\u4e0b\u540c\u6837\u53ef\u4ee5\u8fd9\u6837\u8c03\u7528\u3002<\/p>\n<pre>$pos = strpos(\"hello world\", \"world\");\necho $pos;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5f53\u6211\u4eec\u5728\u63a7\u5236\u5668\u6216\u6a21\u7248\u6587\u4ef6\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u5168\u5c40\u51fd\u6570\u65f6\uff0c\u4e0e\u6b63\u5e38\u7684PHP\u64cd\u4f5c\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4e8c\u3001\u52a9\u624b\u51fd\u6570<\/p>\n<p>\u52a9\u624b\u51fd\u6570\u5728ThinkPHP\u6846\u67b6\u4e2d\u662f\u975e\u5e38\u5e38\u7528\u7684\u6280\u5de7\uff0c\u5b83\u4eec\u662f\u96c6\u6210\u5728\u7cfb\u7edf\u5185\u90e8\u7684\u4e00\u4e9b\u7b80\u5355\u3001\u5b9e\u7528\u7684\u51fd\u6570\uff0c\u4f9b\u5f00\u53d1\u8005\u5728\u7a0b\u5e8f\u4e2d\u968f\u65f6\u8c03\u7528\u3002ThinkPHP\u7684\u52a9\u624b\u51fd\u6570\u5f80\u5f80\u7528tp_\u4f5c\u4e3a\u524d\u7f00\uff0c\u8fd9\u4e5f\u4fbf\u4e8e\u6211\u4eec\u5728\u4ee3\u7801\u4e2d\u8fdb\u884c\u533a\u5206\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u7ecf\u5e38\u4f7f\u7528\u7684tp_log()\u51fd\u6570\u3002<\/p>\n<pre>tp_log('\u4f60\u597d\u554a');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u60f3\u8c03\u7528\u67d0\u4e2a\u52a9\u624b\u51fd\u6570\u5f88\u5bb9\u6613\uff0c\u53ea\u9700\u8981\u5728\u9700\u8981\u7684\u5730\u65b9\u76f4\u63a5\u8c03\u7528\u5373\u53ef\u3002<\/p>\n<p>\u4e09\u3001\u4f7f\u7528\u547d\u540d\u7a7a\u95f4<\/p>\n<p>ThinkPHP\u6846\u67b6\u5927\u91cf\u5229\u7528\u4e86\u547d\u540d\u7a7a\u95f4\u7684\u6982\u5ff5\uff0c\u6765\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406\u6587\u4ef6\u548c\u51fd\u6570\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528\u6846\u67b6\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u547d\u540d\u7a7a\u95f4\u4e5f\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5728controller\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u7c7b\uff0c\u5f15\u7528\u67d0\u4e2a\u547d\u540d\u7a7a\u95f4\uff0c\u7136\u540e\u8c03\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002<\/p>\n<pre>namespace appcontroller;\n\nuse thinkController;\n\nclass Index extends Controller\n{\n    public function index()\n    {\n        $pos = strpos(\"hello world\", \"world\");\n        echo $pos;\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6211\u4eec\u5728\u65b0\u5efa\u7684\u7c7b\u4e2d\u5f15\u5165thinkController\u547d\u540d\u7a7a\u95f4\uff0c\u5e76\u8c03\u7528strpos()\u51fd\u6570\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u662f\u8c03\u7528\u51fd\u6570\u7684\u5e38\u7528\u65b9\u6cd5\u4e4b\u4e00\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fThinkPHP\u6846\u67b6\u4e0b\uff0c\u8c03\u7528\u51fd\u6570\u7684\u51e0\u79cd\u65b9\u6cd5\u4e86\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u7684\u5f00\u53d1\u5de5\u4f5c\u80fd\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fthinkphp\u600e\u4e48\u8c03\u7528\u51fd\u6570\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>thinkphp\u662f\u4e00\u6b3ephp\u7684\u5f00\u53d1\u6846\u67b6\uff0c\u5176\u4e3a\u5e38\u89c1\u7684web\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5feb\u901f\u3001\u7b80\u5355\u3001\u9ad8\u6548\u53ca\u9ad8\u8d28\u91cf\u7684\u5f00\u53d1\u4f53\u7cfb\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u5f00\u53d1\u4e00\u4e2aweb\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f1a\u591a\u6b21\u4f7f\u7528\u4e00\u4e9b\u65b9\u6cd5\u6216\u51fd\u6570\u3002\u800c\u5728thinkphp\u6846\u67b6\u4e0b\uff0c\u5982\u4f55\u8c03\u7528\u51fd\u6570\u5462\uff1f\u672c\u6587\u5c06\u4e3a\u60a8\u4e00\u4e00\u4ecb\u7ecd\u3002 \u4e00\u3001\u5168\u5c40\u51fd\u6570 ThinkPHP\u6846\u67b6\u5141\u8bb8\u8c03\u7528PHP\u5168\u5c40\u51fd\u6570\u3002\u6bd4\u5982\uff0c\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u89c1\u7684PHP\u5168\u5c40\u51fd\u6570\u3002 $pos = strpos(&#8220;hello world&#8221;, &#8220;world&#8221;); echo $pos; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u662fPHP\u4e2d\u975e\u5e38\u5e38\u89c1\u7684\u51fd\u6570\u4e4b\u4e00\u2014\u2014 strpos() \u3002\u800c\u5728ThinkPHP\u6846\u67b6\u4e0b\u540c\u6837\u53ef\u4ee5\u8fd9\u6837\u8c03\u7528\u3002 $pos = strpos(&#8220;hello world&#8221;, &#8220;world&#8221;); echo $pos; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u53ef\u4ee5\u770b\u5230\uff0c\u5f53\u6211\u4eec\u5728\u63a7\u5236\u5668\u6216\u6a21\u7248\u6587\u4ef6\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u5168\u5c40\u51fd\u6570\u65f6\uff0c\u4e0e\u6b63\u5e38\u7684PHP\u64cd\u4f5c\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4e8c\u3001\u52a9\u624b\u51fd\u6570 \u52a9\u624b\u51fd\u6570\u5728ThinkPHP\u6846\u67b6\u4e2d\u662f\u975e\u5e38\u5e38\u7528\u7684\u6280\u5de7\uff0c\u5b83\u4eec\u662f\u96c6\u6210\u5728\u7cfb\u7edf\u5185\u90e8\u7684\u4e00\u4e9b\u7b80\u5355\u3001\u5b9e\u7528\u7684\u51fd\u6570\uff0c\u4f9b\u5f00\u53d1\u8005\u5728\u7a0b\u5e8f\u4e2d\u968f\u65f6\u8c03\u7528\u3002ThinkPHP\u7684\u52a9\u624b\u51fd\u6570\u5f80\u5f80\u7528tp_\u4f5c\u4e3a\u524d\u7f00\uff0c\u8fd9\u4e5f\u4fbf\u4e8e\u6211\u4eec\u5728\u4ee3\u7801\u4e2d\u8fdb\u884c\u533a\u5206\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u7ecf\u5e38\u4f7f\u7528\u7684tp_log()\u51fd\u6570\u3002 tp_log(&#8216;\u4f60\u597d\u554a&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u60f3\u8c03\u7528\u67d0\u4e2a\u52a9\u624b\u51fd\u6570\u5f88\u5bb9\u6613\uff0c\u53ea\u9700\u8981\u5728\u9700\u8981\u7684\u5730\u65b9\u76f4\u63a5\u8c03\u7528\u5373\u53ef\u3002 \u4e09\u3001\u4f7f\u7528\u547d\u540d\u7a7a\u95f4 ThinkPHP\u6846\u67b6\u5927\u91cf\u5229\u7528\u4e86\u547d\u540d\u7a7a\u95f4\u7684\u6982\u5ff5\uff0c\u6765\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406\u6587\u4ef6\u548c\u51fd\u6570\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528\u6846\u67b6\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u547d\u540d\u7a7a\u95f4\u4e5f\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5728controller\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u7c7b\uff0c\u5f15\u7528\u67d0\u4e2a\u547d\u540d\u7a7a\u95f4\uff0c\u7136\u540e\u8c03\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002 namespace appcontroller; use thinkController; class Index extends Controller { public function index() { $pos = strpos(&#8220;hello world&#8221;, &#8220;world&#8221;); echo $pos; } } [&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-22712","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22712","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=22712"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22712\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}