<!--in header.balde.php -->
$data = 'Hellow World'; // assigned a variable
{{ $data }} // echo hellow world // its working
//in content.blade.php
{{ $data }} // undefined variable it not comes on content // I have to must
get variable data from header.blade.php
//Main Template.blade.php
@include('header')
@include('content')
@include('footer')
?>我想将变量赋值给header.blade.php并返回到content.blade.php
发布于 2017-06-03 14:35:10
您可以使用会话将数据存储在其中并在工程中的任何位置使用它
Session::put('data', $data);并在刀片中将其用作
Session::get('data');发布于 2017-06-03 14:54:19
您可以像这样在刀片中传递数据
public function example(){
$data = 'hello world';
return view('blade_template' compact('data'));
}然后在视图中,只需使用{{ $data }}打印值
https://stackoverflow.com/questions/44341029
复制相似问题