The Laravel5 framework transfers data to the view (Advanced article), laravel framework. The Laravel5 framework learns how to transfer data to a view (Advanced article). The laravel framework not only transfers data to a view, but also transmits the code for copying an Array as follows: laravel 5 framework-transfer data to views (Advanced article); laravel framework
We can not only transmit a data record to a view, but also an Array
The code is as follows:
Public function about ()
{
Return view ('Pages. about')-> ([
'First' => 'Zhang ',
'Last' => 'jinglin'
]);
}
About {$ first }{{$ last }}
A simple method is as follows:
The code is as follows:
Public function about ()
{
$ Data = [];
$ Data ['first'] = 'zhang ';
$ Data ['last'] = 'jinglin ';
Return view ('Pages. about', $ data );
}
The results are the same, which is simpler:
The code is as follows:
Public function about ()
{
$ First = 'Zhang ';
$ Last = 'jinglin ';
Return view ('Pages. about', compact ('first ', 'last '));
}
Compact converts parameters into arrays, and extract is the opposite. You can refer to the php Manual to learn about compact and learn about extract by the way.
Http://www.bkjia.com/PHPjc/980217.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/980217.htmlTechArticleLaravel 5 framework learning to transfer data to a view (advanced), laravel framework we can not only transfer a data to a view, we can also transmit the Array code as follows :...