The difference between php $_POST and php://input

WBOY
Release: 2016-08-08 09:25:32
Original
921 people have browsed it

1.$_POST and php tutorial: input can get the value, $HTTP_RAW_POST_DATA is empty$_POST organizes the submitted data in an associative array, and encodes it, such as urldecode, and even encoding conversion php: input can also be achieved This function can get the original POST

2. Use curl post to pass json. Our regular $_POST method cannot be accepted. There is a way to accept it, which is to wrap an array around the json data. , you can use file_get_contents("php://input") to receive the post data without including array

3. Simulate a form and take a look:





post.php


php://input allows reading the raw data of POST . It puts less pressure on memory than $HTTP_RAW_POST_DATA and does not require any special php.ini settings. php://input cannot be used with enctype="multipart/form-data".


php $_POST

$_POST variable is an array whose content is the variable name and value sent by the HTTP POST method.

$_POST variable is used to collect values ​​from the form with method="post". Information sent from a form with the POST method is invisible to anyone (it does not appear in the browser's address bar), and there is no limit on the amount of information sent.

html


Enter your name:
Enter your age: < ;input type="text" name="age" />

welcome.php

Welcome .

You are years old!

Variables sent via HTTP POST will not be displayed in the URL middle.
Variables have no length limit


The above has introduced the difference between php $_POST and php://input, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template