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

09-19 06:38