I’m trying my new hand at Code Igniter and have this issue come up.
( ! ) Fatal error: Class ‘Controller’ not found in C:\wamp\www\kowmanager\system\application\controllers\user.php on line 2
Call Stack
Time Memory Function Location
1 0.0007 695640 {main}( ) ..\index.php:0
2 0.0021 782824 require_once( ‘C:\wamp\www\kowmanager\system\core\CodeIgniter.php’ ) ..\index.php:201
3 0.0181 1938352 include( ‘C:\wamp\www\kowmanager\system\application\controllers\user.php’ ) ..\CodeIgniter.php:248
<?php
class User extends Controller {
function User()
{
parent :: Controller();
$this->view_data['base_url'] = base_url();
}
function index()
{
$this->register();
}
function register()
{
$this->load->view('view_register', $this->view_data);
}
}
?>
EDIT:
I changed the class User extends CI_Controller but now I’m getting this:
Fatal error: Call to undefined method CI_Controller::Controller() in C:\wamp\www\kowmanager\system\application\controllers\user.php on line 6
Edit 2:
Here is my new code. Im getting Fatal error: Call to undefined method CI_Controller::User() in C:\wamp\www\kowmanager\system\application\controllers\user.php on line 6
<?php
class User extends CI_Controller {
function User()
{
parent :: User();
$this->view_data['base_url'] = base_url();
}
function index()
{
$this->register();
}
function register()
{
$this->load->view('view_register', $this->view_data);
}
}
?>
check this link. Codeigniter constructors. What is the difference?
It seems you are using CodeIgniter 2+ and PHP 5. With which the old constructor method no longer works.
Ah, since I think you are using PHP 5.
You should use __construct() instead.
Or replace the function name also so it’s much readable as overriding the parent constructor method.