PHP 经常性地使用信息传输,这也是 PHP 为实现动态网页应运而生地缘由,对于信息量极少的,我们可能会使用 GET ,但是数据内容较多时我们会使用 POST ,本文就带大家一起来看一看。

PHP经常性地使用信息传输,这也是PHP为实现动态网页应运而生地缘由,对于信息量极少的,我们可能会使用GET,但是数据内容较多时我们会使用POST,本文就带大家一起来看一看。
首先我们先写一个html页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="test.php" method="POST">
<label for="username">账号:</label>
<input type="text" id="username" name="username">
<label for="password">密码:</label>
<input type="text" id="password" name="password">
<input type="submit" value="提交">
</form>
</body>
</html>
php验证页面:test.php
<?php $name=$_POST['username']; $pass=$_POST['password']; echo "用户名:".$name."<br>"; echo "密码:".$pass."<br>"; ?>
输出:用户名:lilil
密码:4561212
