The problem is with this code, and this is not always obvious:
class Index extends Controller ^^^^^ { public function index() ^^^^^ { $this->load->view("hello_world"); } }
This is the same name and, therefore, a constructor with reverse support for PHP 4. Then the parent constructor is not called, $load not installed and the function is not defined.
Knowing this, there are many solutions, including:
namespace DelishusCake;
Enter namespace
This automatically fixes your problem. You need to place this on top of the file.
class Index extends Controller { public function index($load = NULL) { isset($load) && $this->load = $load; $this->load->view("hello_world"); } }
Make a constructor with backward compatibility PHP4
Or:
class MyIndex extends Controller { public function index() { $this->load->view("hello_world"); } }
Rename class
Or:
class Index extends Controller { public function __construct($load) { parent::__construct($load); } public function index() { $this->load->view("hello_world"); } }
Add PHP 5 constructor, call parent constructor
Keep in mind that you only need this because it is the same name. You can find a detailed description in the PHP manual on the page "Constructors and destructors" .
hakre source share