Why can't my view access the same variable that my controller can in CodeIgniter
When I do print_r($info); inside my controller, the expected data is shown:
Array (
[message] => Usu.
[value] => 1
)
Inside my view, I get a Notice when trying to access the same variable:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: info
Filename: views/administration.php
Line Number: 4
Inside my controller, I've tried to change the following line:
$this->load->view('administration', (object) $info);
$this->load->view('administration', $info);
$this->load->view('administration');
Controller:
load->library('session');
}
function index()
{
$this->load->model('setup_model');
$this->setup_model->initialisation();
// Load admin model
$this->load->model('administration_model');
// Afficher l'administration
$info = $this->administration_model->log();
print_r($info); // Array ( [message] => Usu. [value] => 1 )
$this->load->view('administration', $info);
}
}
View:
load->helper('form');
$title = "Administration";
$error = $info["message"];
$output = "";
if ($info["value"]) {
$noticeClass = "goodNotice";
} else {
$noticeClass = "errorNotice";
$output .= form_open('admin');
$output .= 'Username
';
$output .= '';
$output .= 'Password
';
$output .= '';
$output .= '';
$output .= '';
}
?>