<!--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
您可以使用会话将数据存储在此中并在项目中的任何地方使用
Session::put('data', $data);
并将其用作
Session::get('data');
您可以像这样的刀片中传递数据
public function example(){
$data = 'hello world';
return view('blade_template' compact('data'));
}
然后,只需使用{{ $data }}
即可打印值