I can't figure out why this code is outputting a Notice error
<?php
class Dashboard extends CI_Controller {
public $data = array();
public function __construct()
{
parent::__construct();
$this->data['brand_title'] = 'Company Brand';
}
public function index()
{
echo $brand_title;
}
}
I get a Undefined variable: brand_title error.
You can access it like this:
echo $this->data['brand_title'];
If you prefer your way, you could do it like this:
extract($this->data);
echo $brand_title;
But extract()
is generally considered bad practice.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments