【发布时间】:2015-03-22 12:13:38
【问题描述】:
我是 CodeIgniter 的新手。我有一个与控制器中的功能有关的问题。控制器中的索引功能如下所示。
public function index()
{
$data = new stdClass;
$data->words = "Apple";
$data->shuffled_words = str_shuffle("Apple");
$this->load->view('t/header');
$this->load->view('projects/game', $data);
$this->load->view('t/footer');
}
但是我已经在两个函数中编写了索引函数。有什么错误没有奏效。
public function index()
{
$this->shuffle();
$this->load->view('t/header');
$this->load->view('projects/game', $data);
$this->load->view('t/footer');
}
public function shuffle()
{
$data = new stdClass;
$data->words = "Apple";
$data->shuffled_words = str_shuffle("Apple");
}
你能帮我解决这个问题吗?
【问题讨论】:
-
您可以使用 $this 调用相同的类函数。我猜你有 $data 变量的错误?
标签: function codeigniter class object stdclass