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

黄舟
黄舟

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

répondre à tous(2)
小葫芦

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

Ty80

compact('comments')=$comments

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!