Laravel HTTP 状态码“1”无效错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40203989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:39:12  来源:igfitidea点击:

Laravel HTTP status code "1" is not valid error

phplaravellaravel-5laravel-5.2

提问by Jaskaran Singh Puri

I'm trying to access my url at: http://localhost/app/public/questions/1

我正在尝试访问我的网址: http://localhost/app/public/questions/1

My Routes

我的路线

 $this->get('/questions/{question_id}','questionController@show');

My controller

我的控制器

public function show($question_id) {

    $showQuestion=questions::findOrFail($question_id);
    return redirect('questions',compact('showQuestion'));
}

For some reason I'm getting this error

由于某种原因,我收到此错误

InvalidArgumentException in Response.php line 458:
The HTTP status code "1" is not valid.

What could be the problem?

可能是什么问题呢?

回答by Jay Bryan Ca?as

I guess you are trying to return a view

我猜你是想返回一个视图

public function show($question_id) {

    $showQuestion=questions::findOrFail($question_id);
    return view('questions')->with('question', $showQuestion);
}

Source

来源

回答by markdwhite

After having something similar myself, maybe you should be using:

在我自己有类似的东西之后,也许你应该使用:

return redirect('questions')->with('showQuestion', $showQuestion);