Home  >  Article  >  Backend Development  >  PHP $_POST

PHP $_POST

WBOY
WBOYOriginal
2016-06-23 14:36:05878browse

$_POST 变量用于收集来自 method="post" 的表单中的值。

$_POST 变量

$_POST 变量是一个数组,内容是由 HTTP POST 方法发送的变量名称和值。

$_POST 变量用于收集来自 method="post" 的表单中的值。从带有 POST 方法的表单发送的信息,对任何人都是不可见的(不会显示在浏览器的地址栏),并且对发送信息的量也没有限制。

例子
Enter your name: Enter your age:

当用户点击提交按钮,URL 不会含有任何表单数据,看上去类似这样:

http://www.w3school.com.cn/welcome.php

"welcome.php" 文件现在可以通过 $_POST 变量来获取表单数据了(请注意,表单域的名称会自动成为 $_POST 数组中的 ID 键):

Welcome .
You are years old!

为什么使用 $_POST? 通过 HTTP POST 发送的变量不会显示在 URL 中。 变量没有长度限制。

不过,由于变量不显示在 URL 中,所有无法把页面加入书签。

$_REQUEST 变量

PHP 的 $_REQUEST 变量包含了 $_GET, $_POST 以及 $_COOKIE 的内容。

PHP 的 $_REQUEST 变量可用来取得通过 GET 和 POST 方法发送的表单数据的结果。

例子
Welcome .
You are years old!
Statement:
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