为什么我不能传递在代码点火器控制器的构造函数中初始化的值


Why can I not pass values initialized in the constructor of my Code Igniter controller?

我在代码点火器应用程序中有这个控制器。值在构造函数中初始化。

class Cat extends CI_Controller {
    private $data = array();
    public function __construct() {
        parent::__construct();
        $this->data['sound'] = "meow";
    }                                 
    public function index() {
        $this->load->view('myCatPage', $data); 
    }
}

视图"views/myCatPage.php"如下所示。这很简单。

<?= $sound ?>

为什么 PHP 会注意到此错误?

Message: Undefined variable: sound

以为我把这个变量作为我发送到视图中的数组($data)中的一个键发送。我试过了

$this->load->view('myCatPage', $this->data);

但奇怪的是,这也失败了。

class Cat extends CI_Controller {
    var $data = array();
    public function __construct() {
        parent::__construct();
        $this->data['sound'] = "meow";
    }                                 
    public function index() {
        $this->load->view('myCatPage', $this->data); 
    }
}