_POST和_GET
$_GET[](引荐进修:PHP编程从入门到通晓)
形貌:猎取表单 method = “get” 提交的数据
举例:$username = $_GET[“username”];
$_POST[]
形貌:猎取表单 method = “post” 提交的数据
举例:$username = $_POST[“username”];
先拿_POST做一个例子。
我在我站点的index.html中写入下面的代码。
意义是建立一个表单,这个表单提交用的要领是 post要领,new.php会处置惩罚这个表单。这个表单有两个输入框,他们的名字分别是name和age,另有一个确认按纽,它的名字是submit,确认按纽上面的笔墨就是submit。
<form action ="new.php" method = "post" > <p>name:<input type ="text" name= "name"></p> <p>age:<input type = "text" name= "age"></p> <p><input type ="submit" name = "submit" value ="submit"></p> </form>
<?php foreach($_POST as $key =>$value) { echo $key . ' => ' . $value . '<br>'; } ?>
再拿 _GET做一个例子。
<form action ="new.php" method = "get" > <p>name:<input type ="text" name= "name"></p> <p>age:<input type = "text" name= "age"></p> <p><input type ="submit" name = "submit" value ="submit"></p> </form>
<?php foreach($_GET as $key =>$value) { echo $key . ' => ' . $value . '<br>'; } ?>
以上就是php怎样猎取表单数据的细致内容,更多请关注ki4网别的相干文章!