SLIM 框架 post 变量始终为空
SLIM Framework post variables always null
我正在使用带有简单 post 路由功能的 SLIM 框架,例如:
$app->post( '/addresses', 'addAddress' );
...
function addAddress()
{
global $app;
$request = $app->request();
$firstname = $request->params('firstname');
echo $firstname;
/* insert into action ... */
}
并想要获取 post 变量,但是如果我使用 Advanced Rest Client 发送 Chrome 的 post 请求,如下所示:
firstname=Test
结果总是空的:(
编辑:
错误是 text/plain 如果我将它设置为 application/x-www-form-urlencoded 它有效
Advanced Rest Client 的错误是 select text/plain,如果我将它设置为 application/x-www-form-urlencoded 它可以工作
我正在使用带有简单 post 路由功能的 SLIM 框架,例如:
$app->post( '/addresses', 'addAddress' );
...
function addAddress()
{
global $app;
$request = $app->request();
$firstname = $request->params('firstname');
echo $firstname;
/* insert into action ... */
}
并想要获取 post 变量,但是如果我使用 Advanced Rest Client 发送 Chrome 的 post 请求,如下所示:
firstname=Test
结果总是空的:(
编辑: 错误是 text/plain 如果我将它设置为 application/x-www-form-urlencoded 它有效
Advanced Rest Client 的错误是 select text/plain,如果我将它设置为 application/x-www-form-urlencoded 它可以工作