2011-11-30 121 views
0

尝试调用父类时,在codeigniter中出现了一些错误。这是我做过什么:在codeigniter中加载父类

class Email extends CI_Controller 
{ 
    function __construct() 
    { 
     parent::Controller(); 
    } 
} 

这是错误:

Fatal error: Call to undefined method CI_Controller::Controller() in C:\xampp\htdocs\ci-nettuts-d3\application\controllers\email.php on line 11

+0

为什么它是CI_Controller而不是Controller?这是哪个版本?我认为它应该是类电子邮件扩展控制器{...但也许它取决于发布版本... –

+0

最新版本是CI_Controller。你可以参考这里 - http://codeigniter.com/user_guide/general/controllers.html – Zhaf

+0

好吧,你需要使用parent :: __ construct();语法作为答案建议。 –

回答

2

哪个CI的版本您使用的?试过parent::__construct();而不是parent::Controller();

+0

我看这个教程 - http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-3/ 他使用父:: Controller();他的代码作品!这就是我litte有点混淆 – Zhaf

+0

@Zhaf可能他们正在使用与php4兼容的代码点火器版本。最新的codeigniter需要php 5.1.2。下面是他们的文档中的一些代码,它建议parent :: __ construct(),http://codeigniter.com/user_guide/general/controllers.html#reserved – Srisa