php与http协议

来源:互联网 发布:什么是js面向对象 编辑:程序博客网 时间:2024/05/29 04:07

摘要: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.1Host: localhostOrigin: http://localhostContent-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’); 获取请求体内的全部内容

0 0