{"id":22904,"date":"2024-11-21T09:41:28","date_gmt":"2024-11-21T01:41:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22904\/"},"modified":"2024-11-21T09:41:28","modified_gmt":"2024-11-21T01:41:28","slug":"%e6%80%8e%e4%b9%88%e8%bf%9b%e5%85%a5thinkphp","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22904\/","title":{"rendered":"\u600e\u4e48\u8fdb\u5165thinkphp"},"content":{"rendered":"<\/p>\n<p><strong>\u4e00\u3001\u5b66\u4e60\u524d\u63d0<\/strong><\/p>\n<p>\u8981\u5b66\u4e60ThinkPHP\uff0c\u9996\u5148\u8981\u5177\u5907PHP\u7684\u57fa\u672c\u77e5\u8bc6\uff0c\u5305\u62ecHTML\u3001CSS\u3001JavaScript\u7b49\u76f8\u5173\u77e5\u8bc6\u3002\u6b64\u5916\uff0c\u8fd8\u9700\u8981\u719f\u6089MySQL\u7b49\u6570\u636e\u5e93\u7684\u57fa\u672c\u64cd\u4f5c\u548c\u4f7f\u7528\u3002<\/p>\n<p><strong>\u4e8c\u3001\u73af\u5883\u914d\u7f6e<\/strong><\/p>\n<p>\u5728\u8fdb\u5165\u65b0\u7684\u5f00\u53d1\u6846\u67b6\u4e4b\u524d\uff0c\u9700\u8981\u5bf9\u5f00\u53d1\u73af\u5883\u8fdb\u884c\u914d\u7f6e\u3002\u4ee5\u4e0b\u4ee5Windows\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u5b9e\u4f8b\uff0c\u9610\u8ff0\u5982\u4f55\u8bbe\u7f6eThinkPHP\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>1.\u5b89\u88c5Web\u670d\u52a1\u5668<\/p>\n<p>\u63a8\u8350\u4f7f\u7528Apache\u6216Nginx\u4f5c\u4e3a\u672c\u5730Web\u670d\u52a1\u5668\u3002\u901a\u8fc7\u5b89\u88c5WampServer\u6216XAMPP\u7b49Web\u670d\u52a1\u5668\u96c6\u6210\u8f6f\u4ef6\uff0c\u4e00\u952e\u5b89\u88c5Apache\u3001MySQL\u7b49\u5e38\u7528\u8f6f\u4ef6\uff0c\u6bd4\u8f83\u65b9\u4fbf\u3002\u4e00\u65e6\u5b8c\u6210\u5b89\u88c5\uff0c\u542f\u52a8\u670d\u52a1\u5668\u5e76\u8bbf\u95eelocalhost\uff0c\u5c31\u4f1a\u8df3\u8f6c\u5230\u670d\u52a1\u5668\u9ed8\u8ba4\u7684\u7f51\u9875\u3002<\/p>\n<p>2.\u4e0b\u8f7d\u5e76\u89e3\u538bThinkPHP<\/p>\n<p>\u8bbf\u95eeThinkPHP\u5b98\u7f51\uff0c\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684ThinkPHP\u6846\u67b6\uff0c\u5e76\u89e3\u538b\u5230\u670d\u52a1\u5668\u7684\u6839\u76ee\u5f55\uff08\u9ed8\u8ba4\u4e3a\uff1aC:wampwww\uff09\u4e0b\uff0c\u5e76\u5c06\u89e3\u538b\u540e\u7684\u6587\u4ef6\u5939\u540d\u547d\u540d\u4e3a\u201c\u201d\u3002<\/p>\n<p>3.\u5b89\u88c5\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>ThinkPHP\u6846\u67b6\u5305\u542b\u591a\u79cd\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u6570\u636e\u5e93\u914d\u7f6e\u548c\u8def\u7531\u4fe1\u606f\u914d\u7f6e\u3002\u53ef\u4ee5\u5728thinkphp\u76ee\u5f55\u4e0b\u590d\u5236\u4e00\u4efd\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6application.example.conf\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3aapplication.conf\u3002<\/p>\n<p>4.\u6d4b\u8bd5\u73af\u5883\u642d\u5efa<\/p>\n<p>\u4e00\u65e6\u6210\u529f\u914d\u7f6e\u597d\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u7f16\u5199\u7b80\u5355\u7684\u6d4b\u8bd5\u9875\u9762\u6765\u9a8c\u8bc1ThinkPHP\u662f\u5426\u5df2\u5b89\u88c5\u548c\u914d\u7f6e\u6210\u529f\u3002\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801\uff0c\u65b0\u5efa\u4e00\u4e2aindex.php\u6587\u4ef6\u5728\u670d\u52a1\u5668\u7684\u6839\u76ee\u5f55\u4e0b\uff1a<\/p>\n<\/p>\n<pre>define('APP_PATH',&nbsp;'.\/Application\/');\ndefine('APP_DEBUG',&nbsp;true);\nrequire&nbsp;'.\/thinkphp\/ThinkPHP.php';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\uff0c\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95eelocalhost\/index.php\uff0c\u5982\u679c\u6210\u529f\u8f93\u51fa\u201cHello, ThinkPHP\u201d\u7b49\u4fe1\u606f\uff0c\u5219\u8bc1\u660e\u73af\u5883\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p><strong>\u4e09\u3001\u57fa\u7840\u67b6\u6784<\/strong><\/p>\n<p>ThinkPHP\u4e3b\u8981\u5305\u62ec\u63a7\u5236\u5668\u3001\u6a21\u578b\u3001\u89c6\u56fe\u3001\u8def\u7531\u7b49\u57fa\u7840\u67b6\u6784\u3002<\/p>\n<p>1.\u63a7\u5236\u5668<\/p>\n<p>\u5728MVC\u6a21\u5f0f\u4e2d\uff0cC\uff08Controller\uff09\u5c42\u88ab\u7528\u4f5c\u63a7\u5236\u5668\uff0c\u5b83\u901a\u8fc7\u5904\u7406\u5e94\u7528\u7a0b\u5e8f\u903b\u8f91\u63a7\u5236\u89c6\u56fe\u548c\u6a21\u578b\u4e4b\u95f4\u7684\u5173\u7cfb\u3002ThinkPHP\u7684\u63a7\u5236\u5668\u4ee3\u7801\u4f4d\u4e8eapplication\u76ee\u5f55\u4e0b\u7684controller\u5b50\u76ee\u5f55\u4e2d\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9700\u8981\u521b\u5efa\u591a\u4e2a\u63a7\u5236\u5668\u6587\u4ef6\u3002<\/p>\n<p>2.\u6a21\u578b<\/p>\n<p>\u6a21\u578b\u662fMVC\u4e2d\u7684M\uff08Model\uff09\u5c42\uff0c\u7528\u4e8e\u5904\u7406\u6570\u636e\u3002\u5728ThinkPHP\u4e2d\uff0c\u6570\u636e\u64cd\u4f5c\u53ef\u4ee5\u4f7f\u7528ORM\u6280\u672f\u7684\u6a21\u578b\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528SQL\u8bed\u53e5\u8fdb\u884c\u67e5\u8be2\u548c\u64cd\u4f5c\u3002The model code is stored in the &#8220;model&#8221; directory of the &#8220;application&#8221; folder.\u3002<\/p>\n<p>3.\u89c6\u56fe<\/p>\n<p>\u89c6\u56fe\u662fMVC\u4e2d\u7684V\uff08View\uff09\u5c42\uff0c\u7528\u4e8e\u751f\u6210\u6700\u7ec8\u7684\u8f93\u51fa\u6a21\u677f\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cThinkPHP\u4e2d\u7684\u89c6\u56fe\u6587\u4ef6\u90fd\u4f1a\u88ab\u4fdd\u5b58\u5728\u4f4d\u4e8eapplication\u76ee\u5f55\u4e0b\u7684view\u6587\u4ef6\u5939\u5185\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528Smarty\u3001Twig\u7b49\u6a21\u677f\u5f15\u64ce\u8fdb\u884c\u89c6\u56fe\u6e32\u67d3\u3002<\/p>\n<p>4.\u8def\u7531<\/p>\n<p>\u8def\u7531\u6280\u672f\u662f\u4e00\u79cdURL\u5730\u5740\u6620\u5c04\u6280\u672f\uff0c\u53ef\u5c06\u8bf7\u6c42\u6620\u5c04\u5230\u76f8\u5e94\u7684\u63a7\u5236\u5668\u548c\u65b9\u6cd5\u3002ThinkPHP\u652f\u6301\u4f7f\u7528\u8def\u7531\u914d\u7f6e\u6587\u4ef6\u6765\u5b9a\u4e49\u548c\u6620\u5c04URL\u5730\u5740\u89c4\u5219\u3002\u5728\u5e94\u7528\u7a0b\u5e8f\u76ee\u5f55\u4e0b\u7684config\u6587\u4ef6\u5939\u4e2d\u5b58\u50a8\u4e86\u8def\u7531\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p><strong>\u56db\u3001\u5b9e\u6218\u64cd\u4f5c<\/strong><\/p>\n<p>\u5728\u5b66\u4e60\u6846\u67b6\u4e4b\u524d\uff0c\u5148\u4ece\u7b80\u5355\u7684\u5b9e\u6218\u64cd\u4f5c\u5f00\u59cb\uff0c\u4e86\u89e3\u5982\u4f55\u4f7f\u7528ThinkPHP\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u9875\u9762\u3002<\/p>\n<p>1.\u521b\u5efa\u63a7\u5236\u5668\u548c\u65b9\u6cd5<\/p>\n<p>\u5728application\/controller\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aIndexController\u7684\u63a7\u5236\u5668\uff0c\u5e76\u5728\u8be5\u63a7\u5236\u5668\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aindex\u7684\u65b9\u6cd5\u3002\u5728\u65b9\u6cd5\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u6570\u7ec4\uff0c\u8be5\u6570\u7ec4\u4e2d\u5305\u542b\u663e\u793a\u5728\u89c6\u56fe\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<p> namespace appcontroller;<\/p>\n<p>class IndexController<br \/>{<\/p>\n<pre>public&nbsp;function&nbsp;index()\n{\n&nbsp;&nbsp;&nbsp;&nbsp;$data&nbsp;=&nbsp;['name'&nbsp;=&amp;gt;&nbsp;'ThinkPHP'];\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$data;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>}<\/p>\n<p>2.\u521b\u5efa\u89c6\u56fe\u6587\u4ef6<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u89c6\u56fe\u6587\u4ef6\uff0c\u540d\u79f0\u4e3aindex.html\uff0c\u5b58\u653e\u4e8eapplication\/view\u76ee\u5f55\u4e0b\u3002\u5728\u89c6\u56fe\u6587\u4ef6\u7684\u6a21\u677f\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528{$name}\u6765\u6307\u5411\u63a7\u5236\u5668\u65b9\u6cd5\u4e2d\u5df2\u5b9a\u4e49\u7684\u6570\u636e\uff0c\u5e76\u5c55\u793a\u5b83\u5728\u89c6\u56fe\u4e2d\u3002<\/p>\n<\/p>\n<pre>&lt;meta&gt;&lt;title&gt;Hello&nbsp;ThinkPHP&lt;\/title&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><\/p>\n<pre>&lt;h2&gt;Hello&nbsp;{$name}&lt;\/h2&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><\/p>\n<p>3.\u8def\u7531\u914d\u7f6e<\/p>\n<p>\u521b\u7acb\u4e00\u4e2a\u8def\u7531\u8bbe\u7f6e\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u4e3aroute.php\uff0c\u4f4d\u4e8eapplication\/config\u76ee\u5f55\u4e0b\u3002\u5728\u8be5\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u8def\u7531\u7684\u89c4\u5219\u548c\u6620\u5c04\u3002<\/p>\n<p> return [<\/p>\n<pre>'\/index'&nbsp;=&amp;gt;&nbsp;'index\/index',<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>];<\/p>\n<p>4.\u8bbf\u95ee\u8def\u7531<\/p>\n<p>\u4f60\u53ef\u4ee5\u542f\u52a8\u670d\u52a1\u5668\uff0c\u7136\u540e\u901a\u8fc7\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95eelocalhost\/index\u6765\u8bbf\u95ee\u8be5\u793a\u4f8b\u9875\u9762\u3002\u9875\u9762\u4e2d\u4f1a\u663e\u793a\u201cHello ThinkPHP\u201d\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8fdb\u5165\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>\u4e00\u3001\u5b66\u4e60\u524d\u63d0 \u8981\u5b66\u4e60ThinkPHP\uff0c\u9996\u5148\u8981\u5177\u5907PHP\u7684\u57fa\u672c\u77e5\u8bc6\uff0c\u5305\u62ecHTML\u3001CSS\u3001JavaScript\u7b49\u76f8\u5173\u77e5\u8bc6\u3002\u6b64\u5916\uff0c\u8fd8\u9700\u8981\u719f\u6089MySQL\u7b49\u6570\u636e\u5e93\u7684\u57fa\u672c\u64cd\u4f5c\u548c\u4f7f\u7528\u3002 \u4e8c\u3001\u73af\u5883\u914d\u7f6e \u5728\u8fdb\u5165\u65b0\u7684\u5f00\u53d1\u6846\u67b6\u4e4b\u524d\uff0c\u9700\u8981\u5bf9\u5f00\u53d1\u73af\u5883\u8fdb\u884c\u914d\u7f6e\u3002\u4ee5\u4e0b\u4ee5Windows\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u5b9e\u4f8b\uff0c\u9610\u8ff0\u5982\u4f55\u8bbe\u7f6eThinkPHP\u5f00\u53d1\u73af\u5883\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b 1.\u5b89\u88c5Web\u670d\u52a1\u5668 \u63a8\u8350\u4f7f\u7528Apache\u6216Nginx\u4f5c\u4e3a\u672c\u5730Web\u670d\u52a1\u5668\u3002\u901a\u8fc7\u5b89\u88c5WampServer\u6216XAMPP\u7b49Web\u670d\u52a1\u5668\u96c6\u6210\u8f6f\u4ef6\uff0c\u4e00\u952e\u5b89\u88c5Apache\u3001MySQL\u7b49\u5e38\u7528\u8f6f\u4ef6\uff0c\u6bd4\u8f83\u65b9\u4fbf\u3002\u4e00\u65e6\u5b8c\u6210\u5b89\u88c5\uff0c\u542f\u52a8\u670d\u52a1\u5668\u5e76\u8bbf\u95eelocalhost\uff0c\u5c31\u4f1a\u8df3\u8f6c\u5230\u670d\u52a1\u5668\u9ed8\u8ba4\u7684\u7f51\u9875\u3002 2.\u4e0b\u8f7d\u5e76\u89e3\u538bThinkPHP \u8bbf\u95eeThinkPHP\u5b98\u7f51\uff0c\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684ThinkPHP\u6846\u67b6\uff0c\u5e76\u89e3\u538b\u5230\u670d\u52a1\u5668\u7684\u6839\u76ee\u5f55\uff08\u9ed8\u8ba4\u4e3a\uff1aC:wampwww\uff09\u4e0b\uff0c\u5e76\u5c06\u89e3\u538b\u540e\u7684\u6587\u4ef6\u5939\u540d\u547d\u540d\u4e3a\u201c\u201d\u3002 3.\u5b89\u88c5\u914d\u7f6e\u6587\u4ef6 ThinkPHP\u6846\u67b6\u5305\u542b\u591a\u79cd\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u6570\u636e\u5e93\u914d\u7f6e\u548c\u8def\u7531\u4fe1\u606f\u914d\u7f6e\u3002\u53ef\u4ee5\u5728thinkphp\u76ee\u5f55\u4e0b\u590d\u5236\u4e00\u4efd\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6application.example.conf\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3aapplication.conf\u3002 4.\u6d4b\u8bd5\u73af\u5883\u642d\u5efa \u4e00\u65e6\u6210\u529f\u914d\u7f6e\u597d\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u7f16\u5199\u7b80\u5355\u7684\u6d4b\u8bd5\u9875\u9762\u6765\u9a8c\u8bc1ThinkPHP\u662f\u5426\u5df2\u5b89\u88c5\u548c\u914d\u7f6e\u6210\u529f\u3002\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801\uff0c\u65b0\u5efa\u4e00\u4e2aindex.php\u6587\u4ef6\u5728\u670d\u52a1\u5668\u7684\u6839\u76ee\u5f55\u4e0b\uff1a define(&#8216;APP_PATH&#8217;,&nbsp;&#8216;.\/Application\/&#8217;); define(&#8216;APP_DEBUG&#8217;,&nbsp;true); require&nbsp;&#8216;.\/thinkphp\/ThinkPHP.php&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u7136\u540e\uff0c\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95eelocalhost\/index.php\uff0c\u5982\u679c\u6210\u529f\u8f93\u51fa\u201cHello, ThinkPHP\u201d\u7b49\u4fe1\u606f\uff0c\u5219\u8bc1\u660e\u73af\u5883\u5b89\u88c5\u6210\u529f\u3002 \u4e09\u3001\u57fa\u7840\u67b6\u6784 ThinkPHP\u4e3b\u8981\u5305\u62ec\u63a7\u5236\u5668\u3001\u6a21\u578b\u3001\u89c6\u56fe\u3001\u8def\u7531\u7b49\u57fa\u7840\u67b6\u6784\u3002 1.\u63a7\u5236\u5668 \u5728MVC\u6a21\u5f0f\u4e2d\uff0cC\uff08Controller\uff09\u5c42\u88ab\u7528\u4f5c\u63a7\u5236\u5668\uff0c\u5b83\u901a\u8fc7\u5904\u7406\u5e94\u7528\u7a0b\u5e8f\u903b\u8f91\u63a7\u5236\u89c6\u56fe\u548c\u6a21\u578b\u4e4b\u95f4\u7684\u5173\u7cfb\u3002ThinkPHP\u7684\u63a7\u5236\u5668\u4ee3\u7801\u4f4d\u4e8eapplication\u76ee\u5f55\u4e0b\u7684controller\u5b50\u76ee\u5f55\u4e2d\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9700\u8981\u521b\u5efa\u591a\u4e2a\u63a7\u5236\u5668\u6587\u4ef6\u3002 2.\u6a21\u578b \u6a21\u578b\u662fMVC\u4e2d\u7684M\uff08Model\uff09\u5c42\uff0c\u7528\u4e8e\u5904\u7406\u6570\u636e\u3002\u5728ThinkPHP\u4e2d\uff0c\u6570\u636e\u64cd\u4f5c\u53ef\u4ee5\u4f7f\u7528ORM\u6280\u672f\u7684\u6a21\u578b\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528SQL\u8bed\u53e5\u8fdb\u884c\u67e5\u8be2\u548c\u64cd\u4f5c\u3002The model code is stored in the &#8220;model&#8221; directory of the &#8220;application&#8221; folder.\u3002 3.\u89c6\u56fe \u89c6\u56fe\u662fMVC\u4e2d\u7684V\uff08View\uff09\u5c42\uff0c\u7528\u4e8e\u751f\u6210\u6700\u7ec8\u7684\u8f93\u51fa\u6a21\u677f\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cThinkPHP\u4e2d\u7684\u89c6\u56fe\u6587\u4ef6\u90fd\u4f1a\u88ab\u4fdd\u5b58\u5728\u4f4d\u4e8eapplication\u76ee\u5f55\u4e0b\u7684view\u6587\u4ef6\u5939\u5185\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528Smarty\u3001Twig\u7b49\u6a21\u677f\u5f15\u64ce\u8fdb\u884c\u89c6\u56fe\u6e32\u67d3\u3002 4.\u8def\u7531 \u8def\u7531\u6280\u672f\u662f\u4e00\u79cdURL\u5730\u5740\u6620\u5c04\u6280\u672f\uff0c\u53ef\u5c06\u8bf7\u6c42\u6620\u5c04\u5230\u76f8\u5e94\u7684\u63a7\u5236\u5668\u548c\u65b9\u6cd5\u3002ThinkPHP\u652f\u6301\u4f7f\u7528\u8def\u7531\u914d\u7f6e\u6587\u4ef6\u6765\u5b9a\u4e49\u548c\u6620\u5c04URL\u5730\u5740\u89c4\u5219\u3002\u5728\u5e94\u7528\u7a0b\u5e8f\u76ee\u5f55\u4e0b\u7684config\u6587\u4ef6\u5939\u4e2d\u5b58\u50a8\u4e86\u8def\u7531\u914d\u7f6e\u6587\u4ef6\u3002 \u56db\u3001\u5b9e\u6218\u64cd\u4f5c \u5728\u5b66\u4e60\u6846\u67b6\u4e4b\u524d\uff0c\u5148\u4ece\u7b80\u5355\u7684\u5b9e\u6218\u64cd\u4f5c\u5f00\u59cb\uff0c\u4e86\u89e3\u5982\u4f55\u4f7f\u7528ThinkPHP\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u9875\u9762\u3002 1.\u521b\u5efa\u63a7\u5236\u5668\u548c\u65b9\u6cd5 \u5728application\/controller\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aIndexController\u7684\u63a7\u5236\u5668\uff0c\u5e76\u5728\u8be5\u63a7\u5236\u5668\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aindex\u7684\u65b9\u6cd5\u3002\u5728\u65b9\u6cd5\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u6570\u7ec4\uff0c\u8be5\u6570\u7ec4\u4e2d\u5305\u542b\u663e\u793a\u5728\u89c6\u56fe\u4e2d\u7684\u6570\u636e\u3002 namespace appcontroller; class IndexController{ public&nbsp;function&nbsp;index() { &nbsp;&nbsp;&nbsp;&nbsp;$data&nbsp;=&nbsp;[&#8216;name&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;ThinkPHP&#8217;]; &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$data; } \u767b\u5f55\u540e\u590d\u5236 [&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-22904","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22904","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=22904"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22904\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}