摘要:php程序员,必须要懂http
一、最常见的http post请求
最常见的http post请求即表单请求。
index.html
<html>
<head>
<title>测试页面
</title>
</head>
<body>
<form action="index.php" method="post">
<input name="username" type="text"><br>
<input name="password" type="text"><br>
<input type="submit">
</form>
</body>
</html>
表单提交的http请求头如下:
POST /test/http/index.php HTTP/1.1
Host:
localhost
Origin:
http://localhost
Content-Type:
application/x-www-form-urlencoded
请求体:
username=
aaa&password=bbb
apache服务器接收到这次Http请求后,将请求消息,转变为php超全局变量,传给php脚本,就是index.php文件。下面详述这几个超全局变量。
$_REQUEST 会接收get或post请求的参数 $_POST http请求体里面的查询字符串转换为数组 file_get_content(‘php://input’); 获取请求体内的全部内容
转载请注明原文地址: https://ju.6miu.com/read-36620.html