任何人都可以看看这个,无法弄清楚为什么最后一行导致以下错误:
语法错误,意外'(',期待标识符(T_STRING)或 变量(T_VARIABLE)或'{'或'$'
public function show($id)
{
$post = Post::find($id);
$date = $post->created_at;
setlocale(LC_TIME, 'GB');
$date = $date->formatlocalized('%A %d %B %Y');
return View::make('posts.show')->('post', $post)with->('date', $date);
}
答案 0 :(得分:1)
扩展@ Log1c初始答案,你已经打开了一个括号:
return View::make('posts.show')->('post', $post)->with('date', $date);
// ^-- HERE, there's no function call
你也可以在那里使用with()
吗?
return View::make('posts.show')->with('post', $post)->with('date', $date);
答案 1 :(得分:0)
相反:
return View::make('posts.show')->('post', $post)with->('date', $date);
它应该是:
return View::make('posts.show')->with('post', $post)->with('date', $date);
在调用方法->
时更改with()
的位置,调用类似with->()
的方法是无效的语法,并且还添加一个with()
。