欢迎各位兄弟 发布技术文章
这里的技术是共享的
谷歌 laravel view to string
laravel view to html
laravel view to variable
laravel view to view
laravel view to json
laravel 4
$view
= View::make(
'my_view'
, [
'name'
=>
'Rishabh'
]);
$contents
= (string)
$view
;
// 或者
$contents
=
$view
->render();
$html = (string) View::make('foo', ['bar' => 'baz']);
// Use render() method instead.
//Your exception will not be "hidden" by __toStrings()'s
// exception restriction.
$html = View::make('foo', ['bar' => 'baz'])->render();
laravel 5
$view
= view(
'my_view'
, [
'name'
=>
'Rishabh'
]);
$contents
= (string)
$view
;
// 或者
$contents
=
$view
->render();
$html = (string) view('foo', ['bar' => 'baz']);
// Use render() method instead.
//Your exception will not be "hidden" by __toStrings()'s
// exception restriction.
$html = view('foo', ['bar' => 'baz'])->render();
laravel 4
[php]
$nav_primary_data = json_decode(file_get_contents('navs/primary.json', true);
$view_string = View::make('layouts.master.navs.primary')->with('nav_primary_data', $data)->render();
[/php]
laravel 5
$nav_primary_data = json_decode(file_get_contents('navs/primary.json', true);
$view_string = view('layouts.master.navs.primary')->with('nav_primary_data', $data)->render();