我在codeigniter控制器中有这个:
<?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);
}
}
初始视图:
<a href="test/hello">INICIO <?php echo $idioma ?></a>
你好视图:
Hello <?php echo $idioma ?>
inicio 视图效果很好,但是当加载 hello 视图时,什么都没有显示。知道为什么这不起作用吗?