一般在页面中常用在表单的操作中,请求数据,
action : 数据提交的地址,默认是当前页面
method : 数据提交的方式,默认是get方式
get:
把数据名称和数据值用=连接,如果有多个的话,那么他会把多个数据组合用&进行连接,然后把数据放到url?后面传到指定页面
enctype : 提交的数据格式,默认application/x-www-form-urlencoded
<body>
<form action="links/1.get.php" enctype="application/x-www-form-urlencoded">
<input type="text" name="username" placeholder="输入名字" />
<input type="text" name="age" placeholder="输入年龄" />
<input type="submit" class="myBtn" value="提交" />
</form>
</body>
出来就是这个样子,
在action请求的php中处理方法:
<?php
header('content-type:text/html;charset="utf-8"');
error_reporting(0);
$username = $_GET['username'];
$age = $_GET['age'];
echo "你的名字:{$username},年龄:{$age}";
get请求的书写方法就是【$_GET】,大小写要求非常严格。