Reputation: 130
$autoload['helper'] = array('url', 'form');
class user extends CI_Controller
{
function user()
{
$this->view_data['base_url']= base_url();
}
function index()
{
$this->regester();
}
function regester()
{
$this->load->view('user_view',$this->view_data);
}
}
Upvotes: 0
Views: 53
Reputation: 25445
Try using a proper constructor for php5:
class User extends CI_Controller
{
private $view_data;
public function __construct()
{
parent::__construct(); // necessary in CI if you declare a constructor
$this->view_data['base_url']= base_url();
}
}
For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, and the class did not inherit one from a parent class, it will search for the old-style constructor function, by the name of the class
Since your class is a child of CI_Controller, which has a __construct()
method, I believe the method User()
in your class isn't being called upon instanciation, and so does base_url()
Upvotes: 1