Home >Backend Development >PHP Tutorial >Php中Get、Post提交怎样通过$_GET、$_POST、$_REQUEST获取

Php中Get、Post提交怎样通过$_GET、$_POST、$_REQUEST获取

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-19 12:15:581127browse

GET表单:
复制代码 代码如下:
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html;charset=gbk"/> 
<title>表单使用GET方式传值</title> 
</head> 
<body> 
<!-- action中的parm参数的值是无法传递到action-get.php的 --> 
<form action="action-get.php?parm=url-get" method="get"> 
<p> 
姓名:<input type="text" name="name" /> 
<!-- 隐藏变量传值 --> 
<input type="hidden" name="hkey" value="hvalue" /> 
<!-- GET表单的隐藏变量传值可以通过$_GET["do"]获取 --> 
<input type="hidden" name="do" value="index" /> 
<!-- submit不设置name属性则不会出现在url中 --> 
<input type="submit" value="提交"/> 
</p> 
</form> 
</body> 
</html>

处理GET表单的PHP:
复制代码 代码如下:
 

<pre class="brush:php;toolbar:false">

<?php 
echo "参数 name 的值通过\$_GET获取为 ".$_GET["name"]." ,"; 
echo "参数 name 的值通过\$_POST获取为 ".$_POST["name"]." ,"; 
echo "参数 name 的值通过\$_REQUEST获取为 ".$_REQUEST["name"]." .\r\n"; 
echo "参数 parm 的值通过\$_GET获取为 ".$_GET["parm"]." ,"; 
echo "参数 parm 的值通过\$_POST获取为 ".$_POST["parm"]." ,"; 
echo "参数 parm 的值通过\$_REQUEST获取为 ".$_REQUEST["parm"]." .\r\n"; 
echo "参数 hkey 的值通过\$_GET获取为 ".$_GET["hkey"]." ,"; 
echo "参数 hkey 的值通过\$_POST获取为 ".$_POST["hkey"]." ,"; 
echo "参数 hkey 的值通过\$_REQUEST获取为 ".$_REQUEST["hkey"]." .\r\n"; 
echo "参数 do 的值通过\$_GET获取为 ".$_GET["do"]." ,"; 
echo "参数 do 的值通过\$_POST获取为 ".$_POST["do"]." ,"; 
echo "参数 do 的值通过\$_REQUEST获取为 ".$_REQUEST["do"]." .\r\n"; 
?> 

处理结果输出:
参数 name 的值通过$_GET获取为 kj ,参数 name 的值通过$_POST获取为 ,参数 name 的值通过$_REQUEST获取为 kj .
参数 parm 的值通过$_GET获取为 ,参数 parm 的值通过$_POST获取为 ,参数 parm 的值通过$_REQUEST获取为 .

1 2 3  下一页
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