Undefined property: Index::$load

I just started to develop a new site with CI.  For now, I only have three view files loaded on my index pages which are made strictly with HTML.  When I visit the index page, I get the following error:

*A PHP Error was encountered
*

*Severity: Notice
*

*Message: Undefined property: Index::$load
*

*Filename: controllers/index.php
*

Line Number: 7

And my controller index.php page as follows:

1
2
3
4
5
6
7
8
9
10
11
<?php  
if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);
class Index extends CI_Controller
{
public function index()
{
$this->load->helper(‘url’);
$this->load->view(‘index’);
}
}
?>

So i just checked, and i found class such Controller,CI_Base,_ci_initialize,Default and index are reserved words .

http://codeigniter.org.cn/user_guide/general/reserved_names.html

Of course, you can also use index as your class name, before your use,add the follow code  is OK:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php  
if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);
class Index extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->helper(‘url’);
$this->load->view(‘index’);
}
}
?>
Author

Ludis

Posted on

2014-07-17

Updated on

2014-07-17

Licensed under

Comments