{"id":319,"date":"2020-06-13T21:59:18","date_gmt":"2020-06-13T13:59:18","guid":{"rendered":"https:\/\/wp.dj47.top\/?p=319"},"modified":"2021-10-20T16:16:17","modified_gmt":"2021-10-20T08:16:17","slug":"tp5%e4%bd%bf%e7%94%a8_get-inputget-%e8%8e%b7%e5%8f%96%e4%b8%8d%e5%88%b0%e6%95%b0%e6%8d%ae%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.djlog.cn\/?p=319","title":{"rendered":"TP5\u4f7f\u7528$_GET \/ input(&#8216;get.&#8217;)\u83b7\u53d6\u4e0d\u5230\u6570\u636e\uff1f"},"content":{"rendered":"<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u4f7f\u7528\u8fc7tp5\u548ctp3\u7248\u672c\u670b\u53cb\uff0c\u4f1a\u53d1\u73b0tp5\u5b8c\u5168\u662fthinkphp\u7684\u4e00\u6b21\u91cd\u6784\u3002\u7ed9\u6211\u4eec\u7684\u4e0d\u662f\u7248\u672c\u7684\u5347\u7ea7\uff0c\u5b8c\u5168\u5c31\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u6846\u67b6\u561b\u3002\u5982\u679c\u7528\u4e60\u60ef\u4e86tp3\uff0c\u65ad\u5d16\u5f0f\u8df3\u5230\u4e86tp5\uff0c\u96be\u514d\u4f1a\u4e0d\u9002\u5e94\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u5176\u4e2d\u5c31\u6709\u4e00\u4e2a\u5bf9$_GET\u8fd9\u4e2a\u5168\u5c40\u53d8\u91cf\u7684\u4f7f\u7528\u95ee\u9898\uff0c\u5728\u6709\u4e9b\u60c5\u51b5\u4e0b\uff0ctp5\u65e0\u6cd5\u4f7f\u7528$_GET\u83b7\u53d6\u6570\u636e\uff1f<\/p>\n<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u5982\u679c\u4f60\u7684\u8bf7\u6c42\u7684\u5730\u5740\u53c2\u6570\u662f\u4ee5pathinfo\u5f62\u5f0f\uff0c\u8fd9\u6837\u53c2\u6570\u662f\u65e0\u6cd5\u7528$_GET\u53bb\u83b7\u53d6\u7684\uff0c\u540c\u6837\u4e5f\u4e0d\u80fd\u4f7f\u7528\u7cfb\u7edf\u4e2d\u7684get\u65b9\u6cd5\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u6bd4\u5982\uff1a<\/p>\n<pre class=\"language-php\"><code>\/\/\u8bf7\u6c42\u5730\u5740\"http:\/\/www.xxx.com\/index\/user\/uid\/100\"\r\npublic function user() {\r\n    print_r($_GET['uid']);  \/\/\u83b7\u53d6\u4e0duid\uff0c\u4f1a\u4e22\u51fa\u4e00\u4e2a\u5f02\u5e38\r\n    print_r(input('get.uid'));  \/\/\u7ed3\u679c\u4e3a\u7a7a\r\n    print_r(input('id'));  \/\/ok\uff0c\u6b63\u5e38\u83b7\u53d6\r\n    print_r(input('param.id'));  \/\/ok,\u6b63\u5e38\u83b7\u53d6\r\n    print_r(Request::instance()-&gt;param('id'));  \/\/ok,\u6b63\u5e38\u83b7\u53d6\r\n    print_r(Request::instance()-&gt;get('id'));  \/\/\u7ed3\u679c\u4e3a\u7a7a\r\n}<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u4ee5\u4e0a\u65b9\u6cd5\u90fd\u662ftp5\u83b7\u53d6\u5e38\u89c1\u7684get\u53c2\u6570\u7684\u83b7\u53d6\u65b9\u5f0f\uff0c\u7ed3\u679c\u80fd\u9a8c\u8bc1\u4e0a\u9762\u7684\u7ed3\u8bba\u3002\u6211\u4eec\u518d\u770b\u770b\u4ee5\u4e0b\u5730\u5740\u8bf7\u6c42\uff1a<\/span><\/p>\n<pre class=\"language-php\"><code>\/\/\u8bf7\u6c42\u5730\u5740\u4e3a\"http:\/\/www.xxx.com\/index\/user?uid=100\"\r\npublic function user() {\r\n    print_r($_GET['uid']);\/\/ok,\u6b63\u5e38\u83b7\u53d6\r\n    print_r(input('get.uid'))\/\/ok,\u6b63\u5e38\u83b7\u53d6\r\n    print_r(input('id'))\/\/ok\uff0c\u6b63\u5e38\u83b7\u53d6\r\n    print_r(input('param.id'))\/\/ok,\u6b63\u5e38\u83b7\u53d6\r\n    print_r(Request::instance()-&gt;param('id'))\/\/ok,\u6b63\u5e38\u83b7\u53d6\r\n    print_r(Request::instance()-&gt;get('id'))\/\/ok,\u6b63\u5e38\u83b7\u53d6\r\n}<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u8fd9\u6837\u666e\u901a\u4f20\u53c2\u65b9\u5f0f\uff0cget\u65b9\u6cd5\u548c$_GET\u5c31\u80fd\u6b63\u5e38\u83b7\u53d6\u3002\u6211\u4eec\u518d\u770b\u770b\u6df7\u5408\u5f0f\u5730\u5740\u65b9\u5f0f<\/span><\/p>\n<pre class=\"language-php\"><code>\/\/\u8bf7\u6c42\u5730\u5740\u4e3a\"http:\/\/www.xxx.com\/index\/user\/uid\/100?name=chenxing\"\r\npublic function user() {\r\n    print_r($_GET);\/\/\u53ea\u80fd\u83b7\u53d6name\u503c\r\n    print_r(input('get.'))\/\/\u53ea\u80fd\u83b7\u53d6name\u503c\r\n    print_r(input(''))\/\/ok\uff0c\u6b63\u5e38\u83b7\u53d6\u6240\u4ee5\u503c\r\n    print_r(input('param.'))\/\/ok,\u6b63\u5e38\u83b7\u53d6\u6240\u4ee5\u503c\r\n    print_r(Request::instance()-&gt;param(''))\/\/ok,\u6b63\u5e38\u83b7\u53d6\u6240\u4ee5\u503c\r\n    print_r(Request::instance()-&gt;get(''))\/\/\u53ea\u80fd\u83b7\u53d6name\u503c\r\n}<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u6df7\u5408\u5f0f\u5730\u5740\u6bd4\u8f83\u4e71\uff0c\u4f46\u5728ajax\u8bf7\u6c42\u65f6\u751f\u6210\u5730\u5740\u5f88\u6709\u53ef\u80fd\u662f\u8fd9\u79cd\u6df7\u5408\u5f0f\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u4e0a\u9762\u7684\u4e09\u79cd\u8bf7\u6c42\u53c2\u6570\u5730\u5740\u5728\u6211\u4eec\u65e5\u5e38\u5f00\u53d1\u4e2d\u6bd4\u8f83\u5e38\u89c1\uff0c\u90a3\u4e48\u80fd\u591f\u6b63\u5e38\u83b7\u53d6\u7684<span style=\"box-sizing: border-box; font-weight: bold; margin: 0px; padding: 0px;\">\u8bf7\u7528\u7cfb\u7edf\u7684param\u65b9\u5f0f\u83b7\u53d6\uff0c\u8fd9\u4e2a\u662f\u6700\u517c\u5bb9\u7684\u83b7\u53d6\u65b9\u5f0f<\/span>\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u56de\u5230\u95ee\u9898\uff0c\u6211\u4eec\u63a2\u7a76\u4e3a\u4ec0\u4e48pathinfo\u4e2d\u7684\u53c2\u6570$_GET\u65e0\u6cd5\u6b63\u5e38\u83b7\u53d6\uff1f\u80fd\u4ea7\u751f\u8fd9\u6837\u7591\u95ee\u7684\u670b\u53cb\u5176\u5b9e\u9677\u5165tp3\u7ed9\u6211\u4eec\u5e26\u6765\u7684\u8ba4\u77e5\u8bef\u533a\u3002\u5728tp3\u4e2d\u4e0a\u9762\u7684\u8bf7\u6c42\u7684\u4e09\u79cd\u65b9\u5f0f\u90fd\u53ef\u4ee5\u7528$_GET\u83b7\u53d6\u5176\u4e2d\u7684\u6240\u6709\u53c2\u6570\uff0c\u4e45\u800c\u4e45\u4e4b\u4f60\u5c31\u4e60\u60ef\u4e86\u8fd9\u79cd\u5199\u6cd5\uff0c\u7136\u540e\u5c31\u628a\u8fd9\u79cd\u83b7\u53d6\u65b9\u5f0f\u53d8\u6210\u7406\u6240\u5f53\u7136\u3002\u6211\u4eec\u6487\u5f00\u6846\u67b6pathinfo\u5730\u5740\u540c\u6837\u65e0\u6cd5\u7528$_GET\u83b7\u53d6\uff0c\u5bf9\u4e8e\u5730\u5740\u4e2d\u7684get\u8bf7\u6c42\u7684\u53c2\u6570\u5fc5\u987b\u662f\u4ee5\u201d\uff1f\u201c\u5f00\u59cb\u7684\u3002\u90a3\u4e48\u4e3a\u4ec0\u4e48tp3\u53ef\u4ee5\u5462\uff1f\u56e0\u4e3atp3\u628apathinfo\u4e2d\u7684\u53c2\u6570\u6574\u5408\u5230\u4e86get\u8bf7\u6c42\u4e2d\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 20px 0px; color: #333333; font-size: 14px; background-color: #ffffff; padding: 0px; font-family: \u5fae\u8f6f\u96c5\u9ed1;\">\u73b0\u5728\u5927\u5bb6\u5e94\u8be5\u80fd\u591f\u660e\u767d\u7684\u611f\u53d7\u5230\u5f00\u5934\u63d0\u5230\u7684tp3\u5230tp5\u8fd9\u79cd\u65ad\u5d16\u5f0f\u5347\u7ea7\u4e86\u5427\u3002\u5fd8\u6389tp3\uff0c\u8ba9tp5\u5728\u6211\u4eec\u624b\u4e2d\u5feb\u6d3b\u7684\u6e38\u8d70\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u8fc7tp5\u548ctp3\u7248\u672c\u670b\u53cb\uff0c\u4f1a\u53d1\u73b0tp5\u5b8c\u5168\u662fthinkphp\u7684\u4e00\u6b21\u91cd\u6784\u3002\u7ed9\u6211\u4eec\u7684\u4e0d\u662f\u7248\u672c\u7684\u5347\u7ea7\uff0c\u5b8c\u5168\u5c31\u662f\u4e24 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[44],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-thinkphp","tag-tp5"],"_links":{"self":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":0,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}