您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

在laravel中遇到compact(),对其中参数不理解

2025/12/15 16:42:21发布34次查看
public function listcomment(){ $comments=comment::orderby('id','desc')->paginate(10); $this->layout->title='comment listings'; $this->layout->main=view::make('dash')->nest('content','comments.list',compact('comments')); }

代码如上,其中compact 参数 为什么是'comments'而不是$comments?
回复内容: public function listcomment(){ $comments=comment::orderby('id','desc')->paginate(10); $this->layout->title='comment listings'; $this->layout->main=view::make('dash')->nest('content','comments.list',compact('comments')); }

代码如上,其中compact 参数 为什么是'comments'而不是$comments?
建议楼主多看看官方文档
http://php.net/manual/zh/function.compact.php
compact('comments')=$comments
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product