{"id":2195,"date":"2023-05-01T11:34:57","date_gmt":"2023-05-01T03:34:57","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2195"},"modified":"2023-05-01T11:35:26","modified_gmt":"2023-05-01T03:35:26","slug":"php-input-stream","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/05\/01\/php-input-stream\/","title":{"rendered":"PHP \u8f93\u5165\u6d41 php:\/\/input"},"content":{"rendered":"<p>\u8f6c\u8f7d\u81f3\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/phper.shujuwajue.com\/shu-zu\/shu-ru-liu-php-input\">https:\/\/phper.shujuwajue.com\/shu-zu\/shu-ru-liu-php-input<\/a><\/p>\n<h2>$_POST \u4e0e php:\/\/input<\/h2>\n<ul>\n<li>\u4ec5\u5728\u53d6\u503c\u4e3a<code>application\/x-www-data-urlencoded<\/code>\u548c<code>multipart\/form-data<\/code>\u65f6(\u6587\u4ef6\u4e0a\u4f20\u65f6)\uff0cphp\u4f1a\u5c06http\u8bf7\u6c42body\u76f8\u5e94\u6570\u636e\u4f1a\u586b\u5165\u5230\u6570\u7ec4<code>$_POST<\/code>\uff0c\u586b\u5165\u5230<code>$_POST<\/code>\u6570\u7ec4\u4e2d\u7684\u6570\u636e\u662f\u8fdb\u884c<code>urldecode()<\/code>\u89e3\u6790\u7684\u7ed3\u679c\u3002<\/li>\n<li>\u53ea\u8981<code>Content-Type<\/code>\u4e0d\u4e3a<code>multipart\/form-data<\/code>\uff0c<code>php:\/\/input<\/code>\u4f1a\u586b\u5165post\u6570\u636e\u3002<\/li>\n<li>\u4ec5\u5f53<code>Content-Type<\/code>\u4e3a<code>application\/x-www-form-urlencoded<\/code>\u4e14\u63d0\u4ea4\u65b9\u6cd5\u662fPOST\u65b9\u6cd5\u65f6\uff0c<code>$_POST<\/code>\u6570\u636e\u4e0e<code>php:\/\/input<\/code>\u6570\u636e\u624d\u662f\u4e00\u81f4\u7684\u3002<\/li>\n<\/ul>\n<h2>$HTTP_RAW_POST_DATA \u4e0e php:\/\/input<\/h2>\n<p><code>php:\/\/input<\/code>\u53ef\u4ee5\u8bfb\u53d6\u6ca1\u6709\u5904\u7406\u8fc7\u7684POST\u6570\u636e\u3002\u76f8\u8f83\u4e8e<code>$HTTP_RAW_POST_DATA<\/code>\u800c\u8a00\uff0c\u5b83\u7ed9\u5185\u5b58\u5e26\u6765\u7684\u538b\u529b\u8f83\u5c0f\u3002<br \/>\n<code>$HTTP_RAW_POST_DATA<\/code>\uff08This feature has been DEPRECATED as of PHP 5.6.0. \u88ab\u5e9f\u5f03\u4e86\uff0c\u67e5\u770b <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/secure.php.net\/manual\/zh\/reserved.variables.httprawpostdata.php\">\u5b98\u65b9\u6587\u6863<\/a>\uff09<br \/>\n\u66f4\u591a<code>php:\/\/input<\/code>\uff0c\u67e5\u770b <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/secure.php.net\/manual\/zh\/wrappers.php.php#wrappers.php.input\">\u5b98\u65b9\u6587\u6863<\/a>\uff09<\/p>\n<p>\u89e3\u6790<\/p>\n<pre><code class=\"language-php\">var_dump($_POST);\necho file_get_contents(&quot;php:\/\/input&quot;);<\/code><\/pre>\n<p>\u60c5\u51b51: \u6587\u4ef6\u4e0a\u4f20\u65f6\uff0cform\u7684<code>enctype=&quot;multipart\/form-data&quot;<\/code>\uff0c\u6b64\u65f6\uff0c\u6570\u636e<code>php:\/\/input<\/code>\u83b7\u53d6\u4e0d\u5230\u6570\u636e<\/p>\n<pre><code class=\"language-php\">&lt;form enctype=&quot;multipart\/form-data&quot; method=&quot;post&quot;&gt;\n&lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;\n&lt;input type=&quot;file&quot; name=&quot;csv_file&quot; \/&gt;\n&lt;button type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;&gt;Submit&lt;\/button&gt;\n&lt;\/form&gt;\n\n&lt;?php\nvar_dump($_POST);\necho &quot;&lt;br&gt;&quot;;\nvar_dump(file_get_contents(&quot;php:\/\/input&quot;));<\/code><\/pre>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a\u53ea\u6709<code>$_POST<\/code>\u83b7\u53d6\u4e86\u6570\u636e<\/p>\n<pre><code class=\"language-php\">array (size=2)\n&#039;name&#039; =&gt; string &#039;test&#039; (length=4)\n&#039;submit&#039; =&gt; string &#039;Submit&#039; (length=6)<\/code><\/pre>\n<p>\u60c5\u51b52: \u975e\u6587\u4ef6\u4e0a\u4f20\u65f6\u7684form\u8868\u5355<\/p>\n<pre><code class=\"language-php\">&lt;form method=&quot;post&quot;&gt;\nname:&lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;&lt;br&gt;\nage:&lt;input type=&quot;text&quot; name=&quot;age&quot; \/&gt;\n&lt;button type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;&gt;Submit&lt;\/button&gt;\n&lt;\/form&gt;\n\n&lt;?php\necho &#039;$_POST result:&lt;br&gt;&#039;;\nvar_dump($_POST);\necho &quot;&lt;br&gt;&quot;;\necho &#039;php:\/\/input result:&lt;br&gt;&#039;;\nvar_dump(file_get_contents(&quot;php:\/\/input&quot;));<\/code><\/pre>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a\u4e24\u8005\u90fd\u4f1a\u83b7\u53d6\u6570\u636e<\/p>\n<pre><code class=\"language-php\">$_POST result:\narray (size=3)\n  &#039;name&#039; =&gt; string &#039;revin&#039; (length=5)\n  &#039;age&#039; =&gt; string &#039;28&#039; (length=2)\n  &#039;submit&#039; =&gt; string &#039;Submit&#039; (length=6)\n\nphp:\/\/input result:\nstring &#039;name=revin&amp;age=28&amp;submit=Submit&#039; (length=31)<\/code><\/pre>\n<p>\u60c5\u51b53\uff1apostman \u76f4\u63a5\u53d1\u9001json body \u4f53\uff0c\u4e5f\u5c31\u662fapi\u7684\u573a\u666f<\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a\u53ea\u6709<code>php:\/\/input<\/code>\u83b7\u53d6\u5230\u4e86\u6570\u636e <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\u81f3\uff1ahttps:\/\/phper.shujuwajue.com\/shu-zu\/shu-ru-liu-php- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[],"class_list":["post-2195","post","type-post","status-publish","format-standard","hentry","category-php-basic"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2195"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2195\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}