2014-03-07 141 views
1

嗨,這是我的代碼,我有一個錯誤在第14行,爲什麼? 我在配置文件中定義了base_url和css。致命錯誤:調用未定義的方法CI_Controller :: CI_Controller()IN Codeigniter

<?php 
     class Start extends CI_Controller{ 
      var $base; 
      var $css; 

      public function Start(){ 
      parent::CI_Controller(); 
      $this->base = $this->config->item('base_url'); 
      $this->css = $this->config->item('css'); 
     } 

     public function hello($name){ 
      $data['css'] = $this->css; 
      $data['base'] = $this->base; 
      $data['mytitle'] = 'Welcome to site'; 
      $data['mytext'] = "Hello, $name, now we're getting dynamic"; 
      $this->load->view('testview', $data); 
     } 
    } 

錯誤:

 Fatal error: Call to undefined method CI_Controller::CI_Controller() in C:\wamp\www\sandbox\application\controllers\start.php on line 14 
+0

嘗試'父:: __結構()'' – naththedeveloper

回答

4

如果你想打電話是CI_Controller的構造函數使用__construct();

public function Start(){ 
    parent::__construct(); 
    $this->base = $this->config->item('base_url'); 
    $this->css = $this->config->item('css'); 
+1

__construct()''不__constructor()' – naththedeveloper

+1

sorry..updated答案.. – Deepak

相關問題