0
我有这样的笨控制器:为什么不能传递控制器功能之间的可变的笨
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Test extends CI_Controller {
public $idioma;
public function index() {
parent::__construct();
// get the browser language.
$this->idioma = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
$data["idioma"] = $this->idioma;
$this->load->view('inicio', $data);
}
public function hello(){
$data["idioma"] = $this->idioma;
$this->load->hello('inicio', $data);
}
}
INICIO视图:
<a href="test/hello">INICIO <?php echo $idioma ?></a>
你好视图:
Hello <?php echo $idioma ?>
inicio视图效果很好,但是当加载hello视图时没有任何显示。 任何想法,为什么这不工作?
'hello()'没有'$ this-> idioma'设置为任何东西。 –