-4

为什么从控制器中的数据库获取数据时出现此错误?我使用 laravel 5.5 和 php 7.2.2。

public function create()
{
    $categories = Category::all();

    return view('post.create'), compact('categories'); 
}

“解析错误:语法错误,意外',',期待';'”返回视图('post.create'),紧凑('类别');

请帮助我,我不知道为什么会出现此错误。

4

2 回答 2

2
public function create()
{
    $categories = Category::all();

    return view('post.create', compact('categories')); 
}
于 2018-02-18T14:32:24.383 回答
0

你关门)太早了。正确的语法是:

return view('post.create', compact('categories')); 
于 2018-02-18T14:31:55.557 回答