php - 在laravel中遇到compact(),对其中参数不理解
黄舟
黄舟 2017-04-10 15:06:59
0
2
763
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?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
小葫芦

建议楼主多看看官方文档
http://php.net/manual/zh/function.compact.php

Ty80

compact('comments')=$comments

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!