【问题标题】:SLIM Framework post variables always nullSLIM 框架发布变量始终为空
【发布时间】:2015-05-09 10:07:27
【问题描述】:

我正在使用带有简单后路由功能的 SLIM 框架,例如:

$app->post( '/addresses', 'addAddress' );

...

function addAddress() 
{
    global $app;
    $request = $app->request();
    $firstname = $request->params('firstname');
    echo $firstname;
   /* insert into action ... */
}

并且想要获取发布变量,但如果我使用 Chrome 的 Advanced Rest Client 发送发布请求,如下所示:

firstname=Test

结果总是 null :(

编辑: 错误是 text/plain 如果我将其设置为 application/x-www-form-urlencoded 它可以工作

【问题讨论】:

    标签: rest post slim


    【解决方案1】:

    错误是为 Advanced Rest Client 选择 text/plain,如果我将其设置为 application/x-www-form-urlencoded 它可以工作

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 2017-07-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-16
      • 2014-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多