【问题标题】:Fatal error: Redefinition of parameter $request [closed]致命错误:重新定义参数 $request [关闭]
【发布时间】:2018-11-10 14:49:53
【问题描述】:

我这里有一个奇怪的错误。我正在使用 Slim 框架构建 REST API。

 $app->post('/createuser', function(Request $request, Response $request){

    if(!haveEmptyParameters(array('email', 'password', 'name', 'school'), $response)){
        $request_data = $request->getParseBody();

        $email = $request_data['email'];
        $password = $request_data['password'];
        $name = $request_data['name'];
        $school = $request_data['school']; ...

错误:

Fatal error: Redefinition of parameter $request in /Applications/XAMPP/xamppfiles/htdocs/RestAPIwithSLIM/public/index.php on line 17

我不知道这个帖子功能缺少哪个参数。

有什么想法吗?

【问题讨论】:

  • 你有Request $request, Response $request - 两者同名!

标签: php slim


【解决方案1】:

您已经定义了两个同名的参数,最好将第二个参数更改为$response

$app->post('/createuser', function(Request $request, Response $response) {

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多