[二]超全局变量$_POST,$_REQUEST
[2]超全局变量$_POST,$_REQUEST
test2.php
结果:
1,get请求和post请求的比较
保存收藏夹方面:get比较方便
安全性方面:post>get
数据传输方面:数据传输量一般是由浏览器决定的而不是由http协议决定,由于get请求的传输的数据需要在URL中显示,因此不同的浏览器允许传输的数据量是不同的,而post请求传输数据不受限制。因此:post>get
2,看看$_POST
test1.php
<html> <head> <meta http-equiv="content-type" content="text/html; charset=GBK"/> </head> <body> <h1> 用户注册 </h1> <form action="test2.php" method="POST"> 用户名:<input type="text" name="username"/><br /> 密 码:<input type="text" name="password"/><br /> 性 别:<input type="radio" name="sex" value="female"/>女 <input name="sex" type="radio" value="male"/>男<br /> <input type="submit" value="提交"/> </form> </body> </html>
test2.php
<?php echo "<pre>"; echo print_r($_POST); echo "</pre>"; ?>
结果:
Array ( [username] => 毛泽东习近平 [password] => maozengdong [sex] => female )
用法和$_GET基本一样。
3,$_REQUEST
$_REQUEST既可以接收get请求数据,也可以接收post请求数据,以及Cookie.这个变量不常用。