From cdae2fe1137d875ec4fdf877f0543fec7687f872 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 22 Nov 2025 13:55:50 +0800 Subject: [PATCH] Improve $_POST definition --- language/predefined/variables/post.xml | 17 ++++++++++++++--- language/wrappers/php.xml | 24 +++++++++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/language/predefined/variables/post.xml b/language/predefined/variables/post.xml index 6c7337446..4ab9c42b6 100644 --- a/language/predefined/variables/post.xml +++ b/language/predefined/variables/post.xml @@ -1,11 +1,12 @@ - + + $_POST - HTTP POST 变量 + 来自 HTTP POST 请求的表单数据 @@ -28,7 +29,7 @@ echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!'; ]]> - 假设用户通过 HTTP POST 方式传递了参数 name=Hannes + 假设用户发送了一个包含 name=Hannes 的 POST 请求体。 &example.outputs.similar; @@ -43,6 +44,16 @@ Hello Hannes! &reftitle.notes; ¬e.is-superglobal; + + + 读取与其他内容类型一起发送的 POST 数据(例如 + application/jsonapplication/xml) + 必须使用 php://input。 + 与仅适用于 application/x-www-form-urlencoded 和 + multipart/form-data$_POST 不同, + php://input 提供对请求正文中原始数据的直接访问。 + + diff --git a/language/wrappers/php.xml b/language/wrappers/php.xml index f8fd07742..b69296dd3 100644 --- a/language/wrappers/php.xml +++ b/language/wrappers/php.xml @@ -1,6 +1,6 @@ - + @@ -335,6 +335,28 @@ file_put_contents("php://filter/write=string.rot13/resource=example.txt","Hello + + + + php://input 从请求体中读取 JSON 数据 + + 此例演示了如何使用 php://input + 读取 POST、PUT 和 PATCH 请求中的原始 JSON 数据。 + + + ]]>