{"id":1265,"date":"2021-05-26T18:49:36","date_gmt":"2021-05-26T10:49:36","guid":{"rendered":"http:\/\/www.zyhcoding.club\/?p=1265"},"modified":"2021-05-27T21:13:40","modified_gmt":"2021-05-27T13:13:40","slug":"php%e8%a1%a8%e5%8d%95","status":"publish","type":"post","link":"http:\/\/www.zyhcoding.club\/index.php\/2021\/05\/26\/php%e8%a1%a8%e5%8d%95\/","title":{"rendered":"PHP\u8868\u5355"},"content":{"rendered":"<h4>PHP \u8868\u5355<\/h4>\n<p>\u8868\u5355\u662f\u7528\u6237\u548c\u7ad9\u70b9\u4e4b\u95f4\u4ea4\u4e92\u7684\u4e00\u4e2a\u5e38\u7528\u7684\u65b9\u5f0f\u3002\u7528\u6237\u901a\u8fc7\u586b\u5199\u7f51\u9875\u4e0a\u7684\u8868\u683c\u5e76\u4e14\u70b9\u51fb\u63d0\u4ea4\u6309\u94ae\uff0c\u8868\u5355\u6570\u636e\u4f1a\u88ab\u53d1\u9001\u5230\u670d\u52a1\u5668\u4e3b\u673a\u3002PHP \u4e2d\u7684 <code>$_GET<\/code> \u548c <code>$_POST<\/code> \u53d8\u91cf\u7528\u4e8e\u68c0\u7d22\u8868\u5355\u4e2d\u7684\u4fe1\u606f\uff0c\u6bd4\u5982\u7528\u6237\u8f93\u5165\u3002<\/p>\n<p>\u5728\u5904\u7406HTML\u8868\u5355\u4fe1\u606f\u65f6\uff0cPHP\u80fd\u628a\u6765\u81eaHTML\u9875\u9762\u4e2d\u7684\u8868\u5355\u5143\u7d20\u81ea\u52a8\u53d8\u6210\u53ef\u4f9bPHP\u4f7f\u7528\u3002<\/p>\n<pre><code class=\"language-html\">\/\/ a.html\u6587\u4ef6\n&lt;form action=&quot;b.php&quot; method=&quot;post&quot;&gt;\n    &lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt;\n&lt;\/form&gt;<\/code><\/pre>\n<p>\u5f53\u586b\u5b8c\u4ee5\u4e0a\u8868\u5355\uff0c\u5e76\u63d0\u4ea4submit\u6309\u94ae\u540e\uff0c\u8868\u5355\u4fe1\u606f\u4f1a\u88ab\u9001\u5230<code>b.php<\/code>\u6587\u4ef6\u4e2d\uff0c\u5e76\u6267\u884c\u76f8\u5173\u64cd\u4f5c\u3002\u5728<code>b.php<\/code>\u6587\u4ef6\u4e2d\u53ef\u4ee5\u7528<code>$_POST[var_name]<\/code>\u6765\u8bbf\u95ee<code>a.html<\/code>\u4e2d\u7684\u5143\u7d20\u503c\u3002<\/p>\n<p>\u5f53\u7136\u4e5f\u53ef\u4ee5<code>action=a.php<\/code>\uff0ca\u6587\u4ef6\u540e\u7f00\u6539\u6210<code>php<\/code>\uff0c\u7136\u540e\u4f7f\u7528<code>isset()<\/code>\u51fd\u6570\u5224\u65ad\u4e00\u4e0b\u662f\u5426\u70b9\u51fb\u63d0\u4ea4\u6309\u94ae\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u628a<code>html<\/code>\u548c<code>php<\/code>\u4ee3\u7801\u5199\u5728\u4e00\u4e2a\u6587\u4ef6\u91cc\u4e86\u3002<\/p>\n<pre><code class=\"language-php\">$name = isset($_POST[var_name])? $_POST[var_name]:&quot;&quot;;\nif ($name) {\n    \/\/ code...\n}<\/code><\/pre>\n<h4><code>$_POST<\/code>\u53d8\u91cf<\/h4>\n<p>\u5728php\u4e2d\uff0c\u9884\u5b9a\u4e49\u7684<code>$_POST<\/code>\u53d8\u91cf\u7528\u4e8e\u6536\u96c6\u6765\u81ea<code>method=&quot;post&quot;<\/code>\u7684\u8868\u5355\u4e2d\u7684\u503c\u3002<br \/>\n\u4ece\u5e26\u6709 POST \u65b9\u6cd5\u7684\u8868\u5355\u53d1\u9001\u7684\u4fe1\u606f\uff0c\u5bf9\u4efb\u4f55\u4eba\u90fd\u662f\u4e0d\u53ef\u89c1\u7684\uff08\u4e0d\u4f1a\u663e\u793a\u5728\u6d4f\u89c8\u5668\u7684\u5730\u5740\u680f\uff09\uff0c\u5e76\u4e14\u5bf9\u53d1\u9001\u4fe1\u606f\u7684\u91cf\u4e5f\u6ca1\u6709\u9650\u5236\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cPOST \u65b9\u6cd5\u7684\u53d1\u9001\u4fe1\u606f\u7684\u91cf\u6700\u5927\u503c\u4e3a 8 MB\uff08\u53ef\u901a\u8fc7\u8bbe\u7f6e <code>php.ini<\/code> \u6587\u4ef6\u4e2d\u7684 <code>post_max_size<\/code> \u8fdb\u884c\u66f4\u6539\uff09\u3002<\/p>\n<h4><code>$_GET<\/code>\u53d8\u91cf<\/h4>\n<p>\u5728 PHP \u4e2d\uff0c\u9884\u5b9a\u4e49\u7684 <code>$_GET<\/code> \u53d8\u91cf\u7528\u4e8e\u6536\u96c6\u6765\u81ea <code>method=&quot;get&quot;<\/code> \u7684\u8868\u5355\u4e2d\u7684\u503c\u3002\u4ece\u5e26\u6709 <code>GET<\/code> \u65b9\u6cd5\u7684\u8868\u5355\u53d1\u9001\u7684\u4fe1\u606f\uff0c\u5bf9\u4efb\u4f55\u4eba\u90fd\u662f\u53ef\u89c1\u7684\uff08\u4f1a\u663e\u793a\u5728\u6d4f\u89c8\u5668\u7684\u5730\u5740\u680f\uff09\uff0c\u5e76\u4e14\u5bf9\u53d1\u9001\u4fe1\u606f\u7684\u91cf\u4e5f\u6709\u9650\u5236\u3002<br \/>\n\u4ece\u5e26\u6709<code>GET<\/code>\u65b9\u6cd5\u7684\u8868\u5355\u53d1\u9001\u7684\u4fe1\u606f\uff0c\u5bf9\u4efb\u4f55\u4eba\u90fd\u662f\u53ef\u89c1\u7684(\u53d1\u9001\u7684\u8868\u5355\u4fe1\u606f\u4f1a\u663e\u793a\u5728\u6d4f\u89c8\u5668\u7684\u5730\u5740\u680f)\uff0c\u5e76\u4e14\u5bf9\u53d1\u9001\u7684\u4fe1\u606f\u91cf\u662f\u6709\u9650\u5236\u7684\u3002<\/p>\n<p>\u4f8b\u5982<code>form.html<\/code>\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-php\">&lt;html&gt;\n&lt;head&gt;\n&lt;meta charset=&quot;utf-8&quot;&gt;\n&lt;title&gt;\u83dc\u9e1f\u6559\u7a0b(runoob.com)&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;form action=&quot;welcome.php&quot; method=&quot;get&quot;&gt;\n\u540d\u5b57: &lt;input type=&quot;text&quot; name=&quot;fname&quot;&gt;\n\u5e74\u9f84: &lt;input type=&quot;text&quot; name=&quot;age&quot;&gt;\n&lt;input type=&quot;submit&quot; value=&quot;\u63d0\u4ea4&quot;&gt;\n&lt;\/form&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>\u5f53\u586b\u5199\u8868\u5355\u4e3a<code>fname=&quot;runoob&quot;, age=&quot;20&quot;<\/code>\u65f6\uff0c\u70b9\u51fb\u63d0\u4ea4\u8868\u5355\u6309\u94ae\u540e\uff0c\u53d1\u9001\u5230\u670d\u52a1\u5668\u7684URL\u4e3a<code>http:\/\/www.runoob.com\/welcome.php?fname=Runoob&amp;age=3<\/code>\uff0c\u53ef\u4ee5\u770b\u5230\u586b\u5199\u7684\u8868\u5355\u4fe1\u606f\u5728\u7f51\u5740\u540e\u9762\u5199\u7740\u3002<\/p>\n<p>\u56e0\u4e3a\u63d0\u4ea4\u8868\u5355\u540eURL\u4f1a\u663e\u793a\u5728\u6d4f\u89c8\u5668\u5730\u5740\u680f\u4e0a\uff0c\u56e0\u6b64\u53ef\u4ee5\u4fdd\u5b58\u6b64\u7f51\u5740\uff0c\u4ee5\u540e\u4e0d\u5fc5\u91cd\u590d\u586b\u5199\uff0c\u5f88\u65b9\u4fbf\u3002<br \/>\n\u5728\u53d1\u9001\u5bc6\u7801\u6216\u8005\u5176\u5b83\u654f\u611f\u4fe1\u606f\u65f6\uff0c\u4e0d\u5e94\u8be5\u4f7f\u7528\u6b64\u65b9\u6cd5\u3002\u540c\u65f6\uff0c<code>GET<\/code>\u65b9\u6cd5\u4e0d\u9002\u5408\u5927\u578b\u7684\u53d8\u91cf\u503c\uff0c\u5b83\u7684\u503c\u662f\u4e0d\u80fd\u8d85\u8fc72000\u4e2a\u5b57\u7b26\u7684\u3002<\/p>\n<h4><code>$_REQUEST<\/code>\u53d8\u91cf<\/h4>\n<p>\u9884\u5b9a\u4e49\u7684<code>$_REQUEST<\/code>\u53d8\u91cf\u5305\u542b\u4e86<code>$_POST<\/code>\u548c<code>$_GET<\/code>\u4ee5\u53ca<code>$_COOKIE<\/code>\u7684\u5185\u5bb9\u3002<code>$_REQUEST<\/code> \u53d8\u91cf\u53ef\u7528\u6765\u6536\u96c6\u901a\u8fc7 <code>GET<\/code> \u548c <code>POST<\/code> \u65b9\u6cd5\u53d1\u9001\u7684\u8868\u5355\u6570\u636e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u8868\u5355 \u8868\u5355\u662f\u7528\u6237\u548c\u7ad9\u70b9\u4e4b\u95f4\u4ea4\u4e92\u7684\u4e00\u4e2a\u5e38\u7528\u7684\u65b9\u5f0f\u3002\u7528\u6237\u901a\u8fc7\u586b\u5199\u7f51\u9875\u4e0a\u7684\u8868\u683c\u5e76\u4e14\u70b9\u51fb\u63d0\u4ea4\u6309\u94ae\uff0c\u8868 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[72],"tags":[],"_links":{"self":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/1265"}],"collection":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/comments?post=1265"}],"version-history":[{"count":7,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/1265\/revisions"}],"predecessor-version":[{"id":1277,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/1265\/revisions\/1277"}],"wp:attachment":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/media?parent=1265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/categories?post=1265"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/tags?post=1265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}