Home Backend Development PHP Tutorial The difference between php $_POST and php://input

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

Aug 08, 2016 am 09:25 AM
input lt php post quot

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:

<form action=" post.php" method="post">
<input type="text" name="user">
<input type="password" name="password">
<input type=" submit">
</form>

post.php

<? echo file_get_contents("php://input");?>


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

<form action="welcome.php" method="post">
Enter your name: <input type="text" name="name" />
Enter your age: &lt ;input type="text" name="age" />
<input type="submit" />
</form>

welcome.php

Welcome <?php echo $_POST[" name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> 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.

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles