Today i am trying to understand coding principles with Code Igniter framework. Nevertheless, i faced with stupid problem.
Here is my controller grades:
<?php
class Grades extends CI_Controller
{
public function view()
{
$data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands');
$data['title'] = "My Real Title";
$data['heading'] = "My Real Heading";
$this->load->view('pages/home', $data);
}
}
?>
And here is mine home:
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<h1><?php echo $heading;?></h1>
<h3>My Todo List</h3>
<ul>
<?php foreach ($todo_list as $item):?>
<li><?php echo $item;?></li>
<?php endforeach;?>
</ul>
</body>
</html>
The output is:
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: pages/home.php
Line Number: 11
Severity: Notice
Message: Undefined variable: heading
Filename: pages/home.php
Line Number: 6
May I have missed something? I would like to find out how to solve this problem.
Routes.php
$route['grades'] = 'grades';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';
$route['404_override'] = '';

$route['default_controller'] = 'Grades'; $route['(:any)'] = 'Grades/$1';- Prix