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

codeigniter, php

Solution

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); 
    }
}

Problem

I have this controller in Code Igniter application. A value is initialized in the constructor. ``` 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); } } ``` The view "views/myCatPage.php" looks like this. It is simple. ``` <?= $sound ?> ``` Why does PHP note this error? ``` Message: Undefined variable: sound ``` I thought I sent this variable as a key in the array (`$data`) I sent into the view. I have tried ``` $this->load->view('myCatPage', $this->data); ``` but that strangely fails too.

Original source