我在将本地开发环境升级到 php8 后阅读了这篇文章。
并在我的课堂上实现它,比如:
<<Attribute('foo')>>
public function index()
{
$posts = (new Post)->get()->withMany('image');
return $this->app()->view('index', compact('posts'));
}
它返回错误。
语法错误,意外标记“<<”,需要“function”或“const”
在 php8 中这样做真正合适的是什么。我错过了什么吗?