小编Jon*_*nas的帖子

代码点火器视图记住以前的变量!

我在控制器中有以下代码:

$data['what'] = 'test';
$this->load->view('test_view', $data);
$this->load->view('test_view');
Run Code Online (Sandbox Code Playgroud)

看法:

<?php
    echo $what;
?>
Run Code Online (Sandbox Code Playgroud)

运行此代码时的结果是:

testtest
Run Code Online (Sandbox Code Playgroud)

难道不应该只是“测试”吗,因为第二次我没有传递变量 $data ?我怎样才能让 CodeIgniter 这样做?

编辑1:

我针对这个问题想出了一个临时解决方法:

在Loader.php中替换:

/*
* Flush the buffer... or buff the flusher?
*
* In order to permit views to be nested within
* other views, we need to flush the content back out whenever
* we are beyond the first level of output buffering so that
* it can be seen and included properly by the first included
* template …
Run Code Online (Sandbox Code Playgroud)

variables codeigniter

5
推荐指数
1
解决办法
1757
查看次数

标签 统计

codeigniter ×1

variables ×1