如何将数组变量(Blade 模板)传递给 CodeIgniter 视图?
How to pass Array Variable (Blade Template) to CodeIgniter View?
我正在使用 https://github.com/cntaoyu/CI-Blade 框架,我的控制器是:
class Welcome extends CI_Controller
{
public function index()
{
$data['student'] = array('rollno' => '1','name' => 'Joyy');
$this->blade->view('welcome_message', $data['student']);
}
}
查看文件
{{$name}} // this prints Joyy
@foreach($student as $users) //student or data, both dont work
<h2>{{ $users }}</h2>
@endforeach
您可以在控制器中传递变量并在视图文件中使用变量的受让人名称。
考虑下面的例子
class Welcome extends CI_Controller
{
public function index()
{
$data['student'] = array('rollno' => '1','name' => 'Joyy');
$this->blade->view('welcome_message', ['students' => $data['student']]);
}
}
查看文件
{{$name}} // this prints Joyy
@foreach($students as $student) //student or data, both dont work
<h2>{{ $student }}</h2>
@endforeach
我正在使用 https://github.com/cntaoyu/CI-Blade 框架,我的控制器是:
class Welcome extends CI_Controller
{
public function index()
{
$data['student'] = array('rollno' => '1','name' => 'Joyy');
$this->blade->view('welcome_message', $data['student']);
}
}
查看文件
{{$name}} // this prints Joyy
@foreach($student as $users) //student or data, both dont work
<h2>{{ $users }}</h2>
@endforeach
您可以在控制器中传递变量并在视图文件中使用变量的受让人名称。 考虑下面的例子
class Welcome extends CI_Controller
{
public function index()
{
$data['student'] = array('rollno' => '1','name' => 'Joyy');
$this->blade->view('welcome_message', ['students' => $data['student']]);
}
}
查看文件
{{$name}} // this prints Joyy
@foreach($students as $student) //student or data, both dont work
<h2>{{ $student }}</h2>
@endforeach