苗条的php(“请求正文"文档的说明) [英] slim php (explanation of "request body" documentation)

查看:62
本文介绍了苗条的php(“请求正文"文档的说明)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用Slim PHP,并且试图理解其中的一个概念.在苗条的PHP文档中,它指出:

I am working with Slim PHP for the first time and I am trying to understand one of the concepts. In the slim PHP documentation, it states:

请求正文

使用请求对象的getBody()方法获取HTTP客户端发送的原始HTTP请求正文.这对于使用JSON或XML请求的Slim应用程序特别有用.

Use the request object’s getBody() method to fetch the raw HTTP request body sent by the HTTP client. This is particularly useful for Slim application’s that consume JSON or XML requests.

<?php
$request = $app->request();
$body = $request->getBody();

我的问题是,什么是原始HTTP请求正文"?它只是页面正文中所有HTML的字符串吗?它以什么格式存储? echo $ body 是什么样的?如果我执行 var_dump($ body),则会得到 string(0)" .我该怎么用?

My question is, what is "the raw HTTP request body"? Is it just a string of all the HTML in the body of the page? What format is it stored as? What would echo $body look like? If I do var_dump($body) I get string(0)"". How do I use it?

推荐答案

您要求的术语在 RFC2616:超文本传输​​协议-HTTP/1.1 .

例如,特别是什么是消息(请求/响应)正文: 4.3消息身体.

For example, in particular what a Message (Request/Response) Body is: 4.3 Message Body.

如果这些RFC是您不熟悉的RFC,请抓住它并从上到下阅读,并尝试尽可能多地理解.您将开始了解互联网中的这些东西是如何工作的.

If those RFCs are new to you, grab that one an read it from top to bottom and try to understand as much as possible. You'll start to see how those things in the internet work.

管道中还有2.0版,但有一些更改:

Also there is version 2.0 is in the pipe with some changes:

以防您感兴趣.

这篇关于苗条的php(“请求正文"文档的说明)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆