使用需要引入 _\Hyperf\HttpServer\Contract\RequestInterface_
函数使用表
| 函数 | 说明 |
|---|---|
| all(): array; | 从请求中检索所有输入数据,包括查询参数、解析体和jsonbody。 |
| query(?string $key = null, $default = null); | 从查询参数中检索数据,如果$key为NULL,则返回所有查询参数。 |
| post(?string $key = null, $default = null); | 从解析体中检索数据,如果$key为NULL,将返回所有解析的正文。 |
| input(string $key, $default = null); | 从请求中检索输入数据,包括查询参数、解析体和json体。 |
| inputs(array $keys, $default = null): array; | 通过多个键检索请求的输入数据,包括查询参数、解析体和JSON体。 |
| hasInput(array $keys): array; | 确定参数中是否存在$键。 |
| has($keys): bool; | 确定参数中是否存在$key。 |
| header(string $key, $default = null); | 从请求头检索数据。 |
| route(string $key, $default = null); | 从路由参数中检索数据。 |
| getPathInfo(): string; | / 返回相对于执行脚本被请求的路径。 路径信息总是以/开头。 假设这个请求是由本地主机上的/mysite实例化的: http://localhost/mysite返回一个空字符串 http://localhost/mysite/aboutreturns ‘/about’ http://localhost/mysite/enco%20ded返回'/enco%20ded‘ http://localhost/mysite/about?var = 1 /对的回报。 @return字符串原始路径(即非urldecoded) / |
| is(…$patterns): bool; | 确定当前请求URI是否与模式匹配。 |
| decodedPath(): string; | 获取请求的当前解码路径信息。 |
| getRequestUri(); | 返回请求的URI(路径和查询字符串)。 |
| url(): string; | 获取请求的URL(没有查询字符串)。 |
| fullUrl(): string; | 获取请求的完整URL。 |
| getQueryString(): ?string; | / 为请求生成规范化查询字符串。 它构建一个规范化查询字符串,其中键/值对按字母顺序排列 保持一致的转义。 @return null|字符串请求的规范化查询字符串 / |
| normalizeQueryString(string $qs): string; | / 规范化查询字符串。 它构建一个规范化查询字符串,其中键/值对按字母顺序排列, 删除一致的转义和不需要的分隔符。 @param字符串$qs查询字符串 @return字符串:请求的规范化查询字符串 / |
| cookie(string $key, $default = null); | 从请求中检索cookie。 |
| hasCookie(string $key): bool; | 确定是否对请求设置了cookie |
| server(string $key, $default = null); | 从请求中检索服务器变量。 |
| isMethod(string $method): bool; | 检查请求方法是否是指定的类型。 |
| file(string $key, $default = null); | 从请求中检索文件。 |
| hasFile(string $key): bool; | 确定上传的数据是否包含文件。 |
